Winter 2021 CST8234 – C Programming XXXXXXXXXXDue Date: March 14th, XXXXXXXXXX:59) Assignment #1 (10% weightage) Dice Game Implementation Problem Statement Specifications: You are to implement a dice...

1 answer below »
see attached file


Winter 2021 CST8234 – C Programming Due Date: March 14th, 2021 (23:59) Assignment #1 (10% weightage) Dice Game Implementation Problem Statement Specifications: You are to implement a dice game in which the user rolls a pair of dice against the computer. The rules of the game are as follows: 1) Generate one play. User roll a pair of dice first and then the computer will do the same. 2) The player rolls the pair of dice and sums up the face values. Outcomes: • If the first roll sum is a 7 or 11, the player wins and return ‘0’ • If the first roll sum is a 2, 3 or 12, the player looses and return ‘1’ • If the sum is other number, player continue rolling the dice until the user get Point Match (PM). PM is set at the first roll. To win, the player must continue rolling the dice until him/her either “makes the highest PM” or roll winning or losing numbers 3) Create a betting amount on each game and carry the sum total of money left using a global variable. Possibilities: • Say a user starts the game with some default money and he/she can only place a bet using multiple of $5 • If the user wins the game, it makes 3 times the bet • If the user loses the game, it loses all the money he/she has bet • You can decide if the user is able to place a bet every time it rolls the dice, or every time it plays a new game. • The money won can get carried over to the next game • If the bet money left is 0, the user can not place any more bets. • When the user decides to finish playing, the amount won should be displayed. Winter 2021 CST8234 – C Programming Due Date: March 14th, 2021 (23:59) Assignment #1 (10% weightage) The following demonstrates a few executions of the program: Winter 2021 CST8234 – C Programming Due Date: March 14th, 2021 (23:59) Assignment #1 (10% weightage) Winter 2021 CST8234 – C Programming Due Date: March 14th, 2021 (23:59) Assignment #1 (10% weightage) Requirements: In order to successfully complete this program and obtain all the marks, you will need to: 1) Define WON and LOST as macros in your program. Use the values of 0 for WON and 1 for LOOSE 2) Implement a function, with function prototype int rollDice( void ):  rollDice( ) should use rand( ) to randomly generate a number between 1 – 6 and should return the number generated by rand( ) 3) Implement a function, with function prototype int playGame( void );  When the player is ready to play, (s)he would use the key ENTER to roll the dice  If the user wins in his/her first roll, congratulate the player and return with WON  If the user looses in his/her first roll, return with LOOSE and apologize  Let the user keep playing until (s)he wins / loses, give an appropriate massage and finish the game with the last roll value. 4) Your main( ) should  Call your function playGame( ) Winter 2021 CST8234 – C Programming Due Date: March 14th, 2021 (23:59) Assignment #1 (10% weightage)  Ask the user if (s)he wants to continue playing another game, keeping track of the numbers of Games lost and won  When the user decides to finish playing, display the number of wins and losses he/she had.  Give the user an appropriate message depending on the number of wins or losses (s)he had while playing  Return with a value of EXIT_SUCCESS 5) Your program should use at least once the conditional operator 6) Write a program must implement ALL the requirements, explicit and implicit, listed in the “Problem Statement Specifications” above. 7) You must distribute your functions in a meaningful manner across multiple .c files. The .c files should contain functions that represent sensible groupings of functionality 8) You must define .h files as appropriate 9) Each function must have a header comments that explain what it does, and describe/explain its inputs (if any) and return value (if any) 10) You must submit makefiles for both codes along with terminal screenshots and text files of your properly commented code. 11) Your program should present information to the user in clear way. In the output given, a table is presented with the number of roll, the value of the first and second dice, the sum total of face values of the dice and the points that the user needs to achieve. 12) Your program should compile with the flags -Wall -ansi –pedantic Deliverables: • Create a folder called algonquinUserID1_algonquinUserID2_A1 (e.g, “mynam00123_yourna45678_A1”) that represents the two members of your team. Only one submission per group is required. You must submit your .c files in the assigned submission folder on BRS section 010 (activities  Assignments). We don’t need your entire project folder. • You will need to demo this code in your lab session, the week of March 15-19th, 2021. During demonstration, you must be able to answer any questions related to the assessment. Winter 2021 CST8234 – C Programming Due Date: March 14th, 2021 (23:59) Assignment #1 (10% weightage) Marking Scheme Item Penalty Coding correctness (functions’ structure) is substandard 3 marks Inappropriate and Inefficient Logic 5 marks Other specification violations 2 marks Defilements in regards to distribution of well-contained functions between files and makefile 5 marks Missed demonstration 15 marks Input validation is inacceptable 10 marks Total Marks Achieved ___Out of 40. Problem Statement Specifications:
Answered 4 days AfterMar 07, 2021

Answer To: Winter 2021 CST8234 – C Programming XXXXXXXXXXDue Date: March 14th, XXXXXXXXXX:59) Assignment #1...

Neha answered on Mar 11 2021
136 Votes
77124 - Dice game/main.c
// The following function can be used to start the dice game between computer and human player. It will
// call the rollDice() function. The wi
nner will be declared after each game and if player wins then
//code will return true else it will return false to the main function of code.
#include
#include
#include
#include
#define WIN 1
#define LOOSE 0
int startGame(int *allgames, int *gameWon)
{
char choice;
scanf("%c", &choice);
int rollCount = 1;
int computer, human;
int totalplayer = 0;
int totalComputer = 0;
int PM = -1; //player's points
while (1)
{
allgames++;
computer = rollDice();
human = rollDice();
totalplayer = (computer + human);
if (PM == -1)
{
printf(" %d \t\t %d \t\t %d \t\t\ %d \t\t ", rollCount, computer, human, totalplayer);
printf("\t\t %d \n", totalplayer);
}
else
{
printf(" %d \t\t %d \t\t %d %d %d \n", rollCount, computer, human, totalplayer, PM);
}
if (totalplayer == 7 || totalplayer == 11 || totalplayer == PM)
{
if (rollCount == 1)
{
printf("Congratulations you roll %d and win at your first try!!!\n", totalplayer);
}
else
{
printf("you roll %d and you win!!!\n", totalplayer);
}
gameWon++;
return WIN;
}
else if (totalplayer == 2 || totalplayer == 3 || totalplayer == 12)
{
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here