Question: Write a program that simulates a game of craps using these rules without human input. Instead of asking for a wage, the program should calculate
Write a program that simulates a game of craps using these rules without human input. Instead of asking for a wage, the program should calculate whether the player would win or lose. The program should simulate rolling 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 (wins/ (wins + losses)) and output this value
Note: To simulate the dice rolling use the Random class to generate numbers between 1 and 6 inclusive.
Methods:


Sample Output

Thank you!
Your program should: Declare the variables numOfWins and numOfLoss to keep track of the number of times player wins or loses Add a loop to your program so that the game is played 10,000 times Add another loop so the player can start a new set of games. Declare a constant for the number of games being played. (10,000) Simulate rolling the two dice and calculate the sum. This first roll will establish the comeOutRoll. (use the Random class to generate random numbers for the dice) Pass this first comeOutRoll to a method called winOrLose. This method will return a string. If it returns: o "seven" means a loss. therefore the variable numOfLoss must be incremented in the main method o "the point" means a win. Therefore, the variable numOfWin must be incremented in the main method. o "win": means a win. Then the variable numOfWins must be incremented in the main method. o "loss": means a loss then the variable numOfLoss must be incremented in the main method. o "The Point": means a point has been established. Therefore set the variable thePoint to the comeOutRoll. Then the method keepRolling must be called to roll the dice until a 7 or "the point" is rolled. This method will return a string: At the end of the 10,000 games, call the method winProbability to compute the probability of winning (wins/wins+ losses) Output the value returned Ask the user if she/he wants to start a new game. Output a good by message if the user does not want to play again
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
