Question: Problem Statement Specifications: You are to implement a dice game in which the user rolls a pair of dice against the computer. The rules





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: 3) 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 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. The following demonstrates a few executions of the program: ROLL THE DICE [ENTER] QUIT TO [q] ROLL NUM DICE#1 2 DICE#2 6 TOTAL ROLL Sorry, computer roll 7 and you loose at first try!!! Another Game? [y/n] ok Please enter only y or n Another Game? [y/n] y ROLL THE DICE [ENTER] QUIT TO [q] ROLL NUM DICE#1 DICE#2 Computer roll 12 and you win!!! Another Game? [y/n] y TOTAL ROLL ROLL THE DICE [ENTER] QUIT TO [4] ROLL NUM DICE#1 DICE#2 TOTAL ROLL 11 Congratulations you roll 11 and win at your first try!!! Another Game? [y/n] y ROLL THE DICE [ENTER] QUIT TO [q] ROLL NUM DICE#1 2 DICE#2 5 TOTAL ROLL 7 Congratulations you roll 7 and win at your first try!!! Another Game? [y/n] y ROLL NUM ROLL THE DICE [ENTER] QUIT TO [4] DICE 1 DICE#2 POINT MATCH POINT MATCH POINT MATCH 11 POINT MATCH TOTAL ROLL POINT MATCH 10 100 You chose to quit and you loose Another Game? [y/n] y ROLL THE DICE [ENTER] QUIT TO [4] ROLL NUM DICE#1 DICE#2 Sorry, computer roll 6 and you loose Another Game? [y/n] n Thank you for playing You won 3 games and lost 3 games! TOTAL ROLL POINT MATCH would you like to bet? [y/n] n ROLL THE DICE [ENTER] QUIT TO [4] ROLL NUM DICE#1 DICE#2 TOTAL ROLL POINT MATCH 3 2 5 11 Congratulations you roll 11 and win!!! Your remainig money is $50 Another Game? [y/n] y Would you like to bet? [y/n] y You have $50, total number of $5 is 10 How many number of $5 would you like to bet? [1-10] Please enter only number between 1-10 You have $50, total number of $5 is 10 How many number of $5 would you like to bet? [1-10] 1 You bet $5 ROLL THE DICE [ENTER] QUIT TO [4] ROLL NUM DICE#1 2 DICE#2 4 TOTAL ROLL 6 Sorry, computer roll 7 and you loose at first try!!! Your remainig money is $45 Another Game? [y/n] y Would you like to bet? [y/n] y You have $45, total number of $5 is 9 How many number of $5 would you like to bet? [1-9] You bet $35 ROLL THE DICE [ENTER] QUIT TO [4] ROLL NUM DICE#1 1 5 POINT MATCH DICE#2 TOTAL ROLL POINT MATCH 3 8 Computer roll 2 and you win!!! Your remainig money is $150 Another Game? [y/n] n Thank you for playing You won 2 games and lost 1 games! Your remainig money is $150 Would you like to bet? [y/n] y You have $50, total number of $5 is 10 How many number of $5 would you like to bet? [1-10] 11 Please enter only number between 1-10 You have $50, total number of $5 is 10 How many number of $5 would you like to bet? [1-18] 3 You bet $15 ROLL THE DICE [ENTER] QUIT TO [q] ROLL NUM DICE#1 4 DICE#2 4 TOTAL ROLL 8 Sorry, computer roll 11 and you loose at first try!!! Your remainig money is $35 Another Game? [y/n] y Would you like to bet? [y/n] y You have $35, total number of $5 is 7 How many number of $5 would you like to bet? [1-7] 7 You bet $35 ROLL THE DICE [ENTER] QUIT TO [q] ROLL NUM DICE#1 DICE#2 Congratulations you roll 8 and win Your remainig money is $140 TOTAL ROLL POINT MATCH POINT MATCH 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() 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
Step by Step Solution
3.41 Rating (154 Votes )
There are 3 Steps involved in it
Create a dice game where the user rolls two dice versus the computer below C language code include include include Global variable to store the total money left int money 100 Function to roll a pair o... View full answer
Get step-by-step solutions from verified subject matter experts
