Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ post screenshots of program and output Write a program that simulates the game of craps, which is played with two dice. On the first

C++
post screenshots of program and output
image text in transcribed
image text in transcribed
image text in transcribed
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 continues. On each subsequent roll, the player wins if he or she rolls the point again. The player loses by rolling a 7. Any other roll is ignored and the game continues. At the end of the each game, the program will ask the user whether or not to play again. When the user enters a response other than 'y' or 'Y', the program will display the total number of wins and losses and then terminate. Specifications: Write the program using three functions: main, rolldice, and playGame. Use the following function prototypes: int rolldice (void); bool playGame (void); rollDice () should generate two random numbers, each between 1 and 6, and return their sum. Use the rand() function to generate random numbers. playGame() 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() function to terminate. In other words, to exit the program: return (EXIT_SUCCESS); As an example, if you execute the program with the following underlined inputs, the output will be: --> main.o Welcome to Craps Please enter a random seed: 23 You rolled: Your point: 4 You rolled: You rolled: You rolled: You rolled: You rolled: You rolled: You lose! Play again? (Y/N): n Wins: Losses: 0 1 -> main.o Welcome to Craps Please enter a random seed: 63 You rolled: You WIN! Play again? (Y/N): Y You rolled: 7 You WIN! Play again? (Y/N): Y You rolled: Your point: 10 10 You rolled: You rolled: You lose! Play again? (Y/N): n Wins: Losses: 2 1 -> main.o Welcome to Craps Please enter a random seed: 152 You rolled: Your point: You rolled: You rolled: unw You WIN! Play again? (Y/N): 9 Wins: Losses: 1 0

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 Database Programming With Visual C# .NET

Authors: Ying Bai

1st Edition

0470467274, 978-0470467275

More Books

Students also viewed these Databases questions

Question

9. Explain the relationship between identity and communication.

Answered: 1 week ago

Question

a. How do you think these stereotypes developed?

Answered: 1 week ago

Question

a. How many different groups were represented?

Answered: 1 week ago