Question: 7. (40 points) Write a Monte Carlo algorithm in Java that computes the probability to win in a game of craps. In this game, we

 7. (40 points) Write a Monte Carlo algorithm in Java that

7. (40 points) Write a Monte Carlo algorithm in Java that computes the probability to win in a game of craps. In this game, we roll two dice and find their sum. There are three possible scenarios leading to a win or loss: If the sum is 7 or 11, we win If the sum is 2, 3, or 12, we lose Otherwise, we roll the dice until we get the initial sum (win) or a sum of 7 (lose) For instance, the following sequences result in a win: - (1,6) // 7 - (6,5) // 11 (2,3), (1,1), (1,4) // initial sum 5 1/2 On the other hand, the following sequences result in a loss: - (1,1) - (2,1) //3 - (4,4), (1,2), (1,6) 1/7 Tips and notes: Write a method that plays a single game of craps Once you have it, you can use it in a loop to count wins vs. #games. The class Random provides nextInt (int n) method which returns a random integer between 0 to n-1

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!