Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 #include using namespace std; int main() { const int TRIALS=10000; int dice1, dice2, sum, point, wins=0, lose=0; strand(time(0)); for (int i = 1; i <= TRIALS; i++)

{

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

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

Objects And Databases International Symposium Sophia Antipolis France June 13 2000 Revised Papers Lncs 1944

Authors: Klaus R. Dittrich ,Giovanna Guerrini ,Isabella Merlo ,Marta Oliva ,M. Elena Rodriguez

2001st Edition

3540416641, 978-3540416647

More Books

Students also viewed these Databases questions