Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 2-Craps In this problem you will implement the popular dice game craps. The following is a brief description of how t of the dice

image text in transcribed
image text in transcribed
image text in transcribed
Part 2-Craps In this problem you will implement the popular dice game craps. The following is a brief description of how t 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? ycenter You rolled: 6 Your point is: 6 You rolled: 8 You rolled: 6 You win! Play again? ycenterr You rolled: 6 Your point is: You rolled: 5 You rolled: 5 You rolled: 11 You rolled: 2 You rolled: 10 You rolled: 9 You rolled: 8 You rolled: 6 You win Play again? Ycenter You rolled: 5 Your point is: 5 You rolled: 4 You rolled: 7 You lose! Play again? ncenter> Wins: 3 Losses:1 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 srandO. If you use it, you will receive zero marks for this problem. The function rollDice is used to determine the outcome of each d 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 player's 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 and losses before it ends When you are ready to submit your work, place all of your functions in a file named Lab5Part2.c (with no main function) for submission

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

More Books

Students also viewed these Databases questions