Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In the game of craps, a pass line bet proceeds as follows. Two six-sided dice are rolled: the first roll of the dice in a

In the game of craps, a pass line bet proceeds as follows. Two six-sided dice are rolled: the first roll of the dice in a craps round is called the come out roll. A come out roll of 7 or 11 automatically wins, and a come out roll of 2, 3, or 12 automatically loses. If 4, 5, 6, 8, 9, or 10 is rolled on the come out roll, that number becomes the point. The player keeps rolling the dice until either 7 or the point is rolled. If the point is rolled first, then the player wins the bet. If a 7 is rolled first, then the player loses. Write a program that simulates a game of craps using these rules without human input the program should use a random number generator to simulate rolling the two dice and calculate the sum. The program should also ask the user how many games they want to play in this simulation, say n. Add a loop so that the program can play n games at a time, and add counters so that the program can keep track of how many times the player wins, and how many times the player loses. At the end, compute the probability of winning (i.e., Wins / (Wins + Losses)) and output this value.

Now add to your program a boolean variable printFlag and set the default value to true. Display details with all dice values only if printFlag is true. If n > 100, set printFlag to false so that only the statistical data will be displayed at the end of execution.

The Game of Craps:

How many games do you want to play in this simulation? 101

In the simulation, you won 53 times and lost 48 times.

The probability of winning is 0.5247524752475248.

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

OpenStack Trove

Authors: Amrith Kumar, Douglas Shelley

1st Edition

1484212215, 9781484212219

More Books

Students also viewed these Databases questions