Problem Statement Specifications: You are to implement a dice game in which the user rolls a...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Answer rating: 100% (QA)
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 the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
You are playing a children's game in which the number of spaces you get to move is determined by the rolling of a die. You must land exactly on the final space to win. If you are 10 spaces away, how...
-
a. Create aMine Field game in which the user attempts to click 10 panels of a grid before hitting the bomb. Set up a JFrame using BorderLayout, use the NORTH region for a congratulatory message, and...
-
You created a game named Quiz in which the user could respond to multiple-choice questions. Modify the game so that it stores the players highest score from any previous game in a file and displays...
-
Alleghany Community College operates four departments. The square footage used by each department is shown below. Alleghany's annual building rental cost is $320,000 What amount of rent expense that...
-
Assume that you are in your first real managerial position. Identify five ways in which you might provide ethical leadership. Rank them in terms of importance, and be prepared to explain your ranking.
-
A jet transport with a landing speed of 200 km/h reduces its speed to 60 km/h with a negative thrust R from its jet thrust reversers in a distance of 425 m along the runway with constant...
-
Given that \(f(x)=\frac{k}{2^{x}}\) is a probability distribution for a random variable that can take on the values \(x=\) \(0,1,2,3\), and 4 , find \(k\).
-
Ceebros Builders is expanding very fast and is expected to grow at a rate of 25 percent for the next four years. The company recently paid a dividend of $3.60 but is not expected to pay any dividends...
-
1. A small company produces a product (X) that requires two types of inputs, A and B during production. Each unit of X requires exactly 5 units of A and 2.5 units of B. If the cost of A is $10 a unit...
-
A two-phase liquid-vapor mixture of H2O with an initial quality of 25% is contained in a piston-cylinder assembly. The mass of the piston is 40 kg, and its diameter is 10 cm. The atmospheric pressure...
-
Given two sequences: x(n) = 28(n) + 38(n 1) - x (n) = 8(n) - 28(n + 2) (a) Find the z-transform of the convolution: [4] X(z) = Z(x(n) * x(n)). (b) Determine the convolution sum using the...
-
Join your teammates and develop your approach to using social media to deliver training. What features would your approach have? For example, would you use a collaborative Facebook-like approach? Why...
-
The traditional training approach is meant to remove a deficit. The use of social media in training can shift the impact of training to supporting performance. Which approach do you think is better?...
-
A workplace situation may be dynamic, but deficiencies in performance can still occur. For example, a selection error might occur and a worker may not have a needed skill. Or, equipment or procedures...
-
When employees leave an organization, they will have to be replaced and the replacement will need to be hired and trained. Estimates vary, but in order to recruit and get an employee up to speed in...
-
Can both the traditional deficit-reduction approach to training and the social media style of training be useful in the same organization? Describe.
-
The origins of these frames are coincident. Show the deduction of the rotation matrix required to rotate the frame with [X1 Y1 Z1] axes 45 degrees counterclockwise as shown in the figure. If the...
-
Southwestern Punch was made by Frutayuda, Inc. and sold in 12-ounce cans to benefit victims of Hurricane Zero. The mean number of ounces placed in a can by an automatic fill pump is 11.7 with a...
-
If you use the automatically supplied default constructor when you create an object, _____________. a. Numeric fields are set to 0 (zero) b. Character fields are set to blank c. Boolean fields are...
-
Which of the following data types can store the value 0 using the least amount of memory? a. short b. long c. int d. byte
-
What is the output of the following code segment? t = 7; if(t > 7) { System.out.print("AAA"); System.out.print("BBB"); } a. AAA b. BBB c. AAABBB d. Nothing
-
We normally think that dissipative forces tend to decrease the velocity of an object. This is correct for isolated systems. Consider the case of an artificial satellite of mass \(m\) in a circular...
-
Determine the work required to transport \(10 \mathrm{~kg}\) of material from Earth to the ISS, the International Space Station, in orbit \(420 \mathrm{~km}\) above the Earth's surface.
-
An artificial satellite of mass \(m=3.4\) ton is in a circular orbit at the altitude \(h_{1}=5000 \mathrm{~km}\). Due to various causes, it gradually loses energy and reaches an altitude \(h_{2}=600...
Study smarter with the SolutionInn App