In the game of craps, a pass line bet proceeds as follows. Two six sided dice ar
ID: 3689756 • Letter: I
Question
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 crap 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 out put this value. Note: to simulate the dice rolling use Random class to generate numbers between 1 and 6 inclusive or you can use the random method from the Math class.Explanation / Answer
/ I create a Die class import java.util.Random; public class Die { private int value; public Die(){ rollDie(); } public int rollDie(){ setDie(new Random().nextInt(6) + 1); return getDie(); } public void setDie(int value){ this.value = value; } public int getDie(){ return value; } } // Testing class which creates the Craps public class Testing { public static int NUM_GAMES = 10000; public static void main(String[] args) { int numWins = 0; int numLosses = 0; Die die1 = new Die(); Die die2 = new Die(); for(int i = 0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.