Question
Write a C++ program that simulates the casino game of craps. These are the rules of the game: If a player throws a 7 or
Write a C++ program that simulates the casino game of craps. These are the rules of the game: If a player throws a 7 or 11 (sum of two dice) the player wins the game. If a player throws a 2, 3 or 12 (sum of two dice) the player loses the game. If a player throws a 4, 5, 6, 8, 9 or 10 (sum of two dice) on the first roll, s(he) neither wins nor loses but creates a point. If this is the case, the player keeps rolling the dice until the point (4, 5, 6, 8, 9 or 10) is being rolled again, and the player wins the game. However, if the player throws a 7 (sum of two dice) before the point is thrown, the player loses the game. Create trials of 10000 times and what is the percentage (in decimals) of you winning.
#include
{
dice1 = rand() % 6 + 1; dice2 = rand() % 6 + 1;
// I'm not sure about the codes starting from here
}
cout << "The number of times you have played is" << TRIALS << "times, and you won" << win << "times, and you lost" << lose << "times. The percentage of winning is" << wins*1.0 / TRIALS << end1;
// the decimals for the winning chance should extend to 6 places.
return 0; }
After debugging it should be something like: The number of times you have played is 10000 times, and you won #### times, and you lost #### times. The percentage of winning is 0.###### Press any key to continue...
Step 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