Question: fig.6.8 java how to to program, 11/e,Early objects Consider the program in Fig. 6.8, change that program in the following ways: 1- Create a separate
fig.6.8 java how to to program, 11/e,Early objects
Consider the program in Fig. 6.8, change that program in the following ways:
1- Create a separate class for the Craps game.
2- Write a method for this new class to run the game and return the game status (replace the main method with this method)
3- Remove all print statements from the Craps class
4- Write a program that runs this game 6 million times and find out the probability of winning and losing the game.
5- Receive a money amount from the user and suppose if they lose the game, they lose the real money, but if they win the game, they receive the double amount as a reward. Determine the expectation for the user's balance after 6 million times the running of the game.







// Fig. 6.8: Craps.java // Craps class simulates the dice game craps. import java.security. SecureRandom; public class Craps \{ 1/ create secure random number generator for use in method ro11Dice private static final SecureRandom randomNumbers = new SecureRandom(): I/ enum type with constants that represent the game status private enum Status \{CONTINUE, WON, LOST \}; I/ constants that represent common rolis of the dice private static final int SNAKE EYES =2; private static final int TREY =3; private static final int SEVEN = 7; private static final int YOLEVEN =11; private static final int BOX_CAR5 =12; Fig. 6.8 | Craps class simulates the dice game craps. (Part 2 of 8.) Fig. 6.8 | Craps class simulates the dice game craps. (Part 3 of 8. ) Fig. 6.8 | Craps class simulates the dice game craps. (Part 4 of 8.) Fig. 6.8 1 Craps class simulates the dice game craps. (Part 5 of 8.) Fig. 6.8 | Craps class simulates the dice game craps. (Part 6 of 8.) Player rolled 5+6=11 Player wins Player rolled 5+4=9 Point is 9 Player rolled 4+2=6 Player rolled 3+6=9 Player wins Player rolled 1+2=3 Player loses Player rolled 2+6=8 Point is 8 Player rolled 5+1=6 Player rolled 2+1=3 Player rolled 1+6=7 Player loses
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
