Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ program to execute the game craps. Rules for the game are below and instructions for the code are afterward. A player rolls

Write a C++ program to execute the game craps. Rules for the game are below and instructions for the code are afterward.

A player rolls two six-sided die, which means he can roll a 1, 2, 3, 4, 5 or 6 on either die. After the dice come to rest they are added together and their sum determines the outcome. If the sum is 7 or 11 on the first roll, the player wins. If the sum is 2, 3, or 12 on the first roll, the player loses (this is called craps). If the player rolls 4, 5, 6, 8, 9, or 10 on the first throw, then that becomes the players point. To win, the player must make their point, that means that they must roll the sum they got on that first throw, so they keep rolling the dice. The player loses by rolling a 7 before making the point.

Write a C++ program that simulates the playing of this game with two players. Your program must have output like that seen below, your actual results will be different due to using random numbers. You will need:

An introduction for your program with instructions and your name.

The players are prompted for a random number seed.

A function that generates the random numbers and prints the results to the interface. Two separate random numbers must be generated for the two die, not the sum. This function returns the toss of one die after the user is prompted to tap the spacebar or any other key.

The program alternates players rolling the die.

The program keeps track of the number of wins for each player.

The program tells the users if player 1 or 2 wins after 3 points are won.

Write the output to a file.

Please make sure to read the instructions carefully. The game is between 2 players. If they roll a 7 or 11 on their first roll, they win. If they roll a 2, 3, or 12 on their first roll, they lose. Any other number rolled on the first roll becomes the number that needs to be summed by either of the 2 players. The players take turns rolling for that number. If either player rolls a 7 afterward, they lose. If they roll the number that needs to be summed, they gain a point. 3 points and they win. However, if they roll a 7 during this period, they lose. They take turns.

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

More Books

Students also viewed these Databases questions