Question
Part 2 Craps In this problem you will implement the popular dice game craps. The following is a brief description of how the game is
Part 2 Craps
In this problem you will implement the popular dice game craps. The following is a brief description of how the game is played. The game of craps is played with two dice. On the rst roll, the player wins if the sum of the dice is 7 or 11. The player loses if the sum is 2, 3, or 12. Any other roll is called a point and the game continues. On each subsequent roll, the player wins if he or she rolls the point again. The player loses by rolling 7. Any other roll is ignored and the game continues. At the end of the game the user has a choice to start a new game by pressing y or Y. Pressing any other key will display the number of wins and losses and then exit the program. A sample run of the program is shown below with data entered by the user displayed using bold font. Your program output will look exactly as below when you run your program in one of the ECF machines with the matching user inputs.
You rolled: 7 You win! Play again? y
Write the following functions with the corresponding prototypes. int rollDice(void); bool playGame(void); void winLoss(void); The function rollDice should generate two random numbers, each between 1 and 6, and return their sum. Use the rand function for rolling each dice to obtain a number between 1 and 6, inclusive. You are not allowed to use the function srand(). If you use it, you will receive zero marks for this problem. The function rollDice is used to determine the outcome of each dice roll. 3 The function playGame should play one craps game. It returns true if the player wins and false if the player loses. For every game of crap, the function playGame calls the function rollDice one or more times, depending upon the value returned by rollDice. playGame is also responsible for displaying messages showing results of the players dice rolls. The function winLoss keeps track of the number of wins and losses in one session. It repeatedly calls the function playGame until the user requests to end the program. winLoss should also report the number of wins and losses before it ends.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started