Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Write a program that simulates the game of craps, which is played with two dice On the first roll, the player wins if the

image text in transcribed
C++
Write a program that simulates the game of craps, which is played with two dice On the first 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 the "point, and the game continucs. On cach subsequent rol, the player wins if he or she rolls the point again. The player loses by rolling a 7. Any other rolsporedandthe g continua At the end of the each game, the program will ask the user whether or mot to play again. When the user enters a response other than "y'or Y", the program will display the total mumber of wins and losses and then terminate. Write the program using three functions: main, rolldice, and playGane. Use the following function prototypes int rol1Dice (void) bool playGame (void) rollDice) should generate two random numbers, each between 1 and 6, and returm their sum Use the rand) function to generate random numbers playGane() should play one craps game (calling rollDice() as many times as necessary to determine the outcome of each dice roll) it will return true if the player wins and false if the player loses (t. play_game is also responsible for displaying messages showing the results of the player's dice rolls main will call play game repeatedly, keeping track of the number of wins and losses, and displaying the "You WIN!" and "You lose!"messages. At the beginning main, after displaying a Welcome to Craps" message, you should prompt the user to enter a random seed (to satisfy the grader program) Finally, use the exit() function and the EXIT SUCCESS constant to exit your program (which are both defined in . From this point forward, each of your programs should use the exit) fanction to terminate. In other words, to exit the progam return(EXIT SUCCESS) As an example, ifyou execute the program with the following underlined isput the ouiput will be: -main.o Welcome to Craps Please enter a randon seed: 23 You rolled: Your point: You rolled: You rolled: You rolled: You rolledi You rolled: You rolled: 11 You lose! Play again? (X/N) a Wins: Losses: 1

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

Database Reliability Engineering Designing And Operating Resilient Database Systems

Authors: Laine Campbell, Charity Majors

1st Edition

978-1491925942

More Books

Students also viewed these Databases questions