Question: Overview For this assignment, write a program that will simulate a single game of Craps. Craps is a game of chance where a player (the

Overview For this assignment, write a program that will simulate a single game of Craps.

Craps is a game of chance where a player (the shooter) will roll 2 six-sided dice. The sum of the dice will determine whether the player (and anyone that has placed a bet) wins immediately, loses immediately, or if the game continues.

If the sum of the first roll of the dice is equal to 7 or 11, the player wins immediately.

If the sum of the first roll of the dice is equal to 2, 3, or 12, the player has rolled "craps" and loses immediately.

If the sum of the first roll of the dice is equal to 4, 5, 6, 8, 9, or 10, the game will continue with the sum becoming the "point." The object of the game is now for the player to continue rolling the dice until they either roll a sum that equals the point or they roll a 7. If the player "makes their point" (i.e. rolls a sum that equals the point), they win. If they roll a 7, they lose.

Random Number Generation The random number generator will be used to "roll" the dice.

If a reminder is needed about how to use the random number generator and how to limit the values that are produced, refer back to program 4:

Link to Program 4

Basic Program Logic Seed the random number generator with a value of 34. Other seed values may be used to produce different results. However, the version that is handed in for grading MUST use a seed value of 34.

Next, roll the dice by generating two random numbers between 1 and 6. The two numbers should be added together and then displayed along with the sum.

If the sum of the dice is equal to 7 or 11, the game is over and the player has won. Display a congratulatory message.

If the sum of the dice is equal to 2, 3, or 12, the game is over and the player has lost. Display a message indicating the player has lost because they rolled craps.

For any other sum, the sum is now the point and the game should continue until the user rolls the point again or rolls a 7. To do this:

Save the sum (the point) in a variable so it can be used for a later comparison

Display the point

Create a boolean variable and initialize it to a value of true to indicate that the game should continue.

In a loop that executes as long as the game should continue:

roll the dice and display the two values along with the sum

if the sum of the dice is the same as the point, display a congratulatory message indicating the player has made their point and they won the game. Also change the boolean variable that controls the loop to false to indicate the game should no longer continue.

otherwise, if the sum of the dice is 7, display a message that the player has lost the game and change the variable that controls the loop to false to indicate the game should no longer continue.

Symbolic Constants The program MUST use at least three symbolic constants. Some options are:

an integer for each of the values (2, 3, and 12) that represents craps on the first roll of the die an integer that represents the value 7 an integer that represents the value 11 Program Requirements Include line documentation. There is no need to document every single line, but logical "chunks" of code should be preceded by a line or two that describes what the "chunk" of code does. This will be a part of every program that is submitted during the semester and this will be the last reminder in the program write-ups.

Make sure to actually use the symbolic constants that are created.

Be sure to #include

Make sure that the copy of the program that is handed in uses srand(34); to set the seed value for the random number generator.

Hand in a copy of the source code (CPP file) using Blackboard.

Output Some runs of the program follow. Each one is marked with the srand value that produced the result.

Output 1 using srand(34); on Windows PC Roll: 6 + 4 = 10

The point is 10

Roll: 5 + 4 = 9 Roll: 5 + 3 = 8 Roll: 3 + 1 = 4 Roll: 5 + 1 = 6 Roll: 3 + 1 = 4 Roll: 3 + 5 = 8 Roll: 6 + 5 = 11 Roll: 1 + 2 = 3 Roll: 2 + 1 = 3 Roll: 6 + 6 = 12 Roll: 6 + 3 = 9 Roll: 4 + 2 = 6 Roll: 5 + 1 = 6 Roll: 3 + 5 = 8 Roll: 1 + 2 = 3 Roll: 6 + 3 = 9 Roll: 2 + 6 = 8 Roll: 6 + 1 = 7

Seven'd out! You lose! Output 2 using srand(19); on Windows PC Roll: 5 + 2 = 7

Seven! Winner!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!