Question
One of the most popular games of chance is a dice game known as craps, played in casinos around the world. Here are the rules
One of the most popular games of chance is a dice game known as craps, played in casinos around the world. Here are the rules of the game:
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.
Part 1: The basic program.
a) Write a C++ program that simulates the playing of this game with two players. You will need: 1. An introduction to your program with instructions and your name. 2. The players are prompted for a random number seed. 3. 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. 4. The program alternates players rolling the die. 5. The program keeps track of the number of wins for each player. 6. The program tells the users if player 1 or 2 wins after 3 points are won. 7. Write the output to a file.
Your program should run something like this.
his program simulates the dice game craps It will simulate the rolling of the dice at the table. You will need to enter a number to seed the game generator Then you can request how many games you would like to play Hope you have lots of fun, and win a few games How many games would you like to play 5 Enter an integer for the random number seed 623 rolled 4 3 7 Player wins Player rolled 6 6 12 Player loses too bad rolled 2 5 Player wins Player rolled 5 4 9 The point to make is 9 Player rolled 4 3 7 Player loses too bad Player rolled 1 5 6 The point to make is 6 Player rolled 5 3 8 Player rolled 3 2 5 Player rolled 3 2 5 Player rolled 6 4 10 Player rolled 5 2 7 Player loses too bad Press any key to continueStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started