Question: JAVA (Format if possible) In the game of craps, a pass line bet proceeds as follows. Two six-sided dice are rolled; the first roll of

JAVA (Format if possible)

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. Instead of asking for a wager, the program should calculate whether the player would win or lose. The program should simulate rolling the two dice and calculate the sum. Add a loop so that the program plays 10,000 games. Add counters that count how many times the player wins, and how many times the player loses. At the end of the 10,000 games, compute the probability of winning [i.e., Wins / (Wins + Losses)] and output this value as a percentage to two decimal places such as: "The odds of winning are 49.27%" (of course this number will vary...). Over the long run, who is going to win the most games, you or the house? Note: To generate a random number X, where 0 <= X < 1, use X = Math.random();. For example, multiplying Math.random() by 6 and converting to an integer results in a random integer that is between 0 and 5. It must all be written within the main method without any additional methods using only local variables. (Sample code to convert decimal results to a percent result:) NumberFormat percentFormatter = DecimalFormat.getPercentInstance(); percentFormatter.setMinimumFractionDigits(2); percentFormatter.setMaximumFractionDigits(2); double result = 0.4556783; // if this is the result System.out.println(percentFormatter.format(result));// this will print 45.57% ( now label the output as mentioned above)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!