Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In the game of Lucky Sevens, the player rolls a pair of dice. If the face values of the dice add up to 7, the

image text in transcribedimage text in transcribed

In the game of Lucky Sevens, the player rolls a pair of dice. If the face values of the dice add up to 7, the player wins $4; otherwise, the player loses $1. Write a C++ program that takes as input the amount of money the player has. The program should play the game until the player has no money. The program should print the number of rolls it took to break the player. Use the random number generator to simulate the rolling of two dice. Keep track of maximum amount of money the player ever had and the number of rolls it took to reach it. See below for a sample input/output. The user should have the option to play again if he/she chooses. Hints: * #include .Seed the random number generator (only needed once at the beginning of the program) srand (time (NULL)); Use the random number generator to generate a random integer between 1 and 6. The following code generates a random number between 0 and 32767 int random int-rand Sample input/output: Enter the amount of oney you have: 100 It took 420 rolls to loose all your money Your maximum was $103.00 and was reached after 6 rolls. Play again (y) ?y Enter the amount of money you have: 20 It took 30 rol1s to loose all your money. Your maximum was $24.00 and was reached after 1 rolls. Play again (y) ?y Enter the amount of money you have: 50 It took 270 rolls to loose all your money Your maximum was $66.00 and was reached after 123 rolls. Play again (y)?n

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

Expert Oracle9i Database Administration

Authors: Sam R. Alapati

1st Edition

1590590228, 978-1590590225

More Books

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago