//Estimate the odd of winning at Craps //Plays a large number of games to report the % wins import java.util.*; public class CrapsOdds { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); //Enter the # of trial games to be played System.out.println("Estimating Craps odds"); System.out.print("How many game trials ? "); int numberOfTrials = keyboard.nextInt(); //Counter: # wins int numberOfWins = 0; int trial = 1; //Repeat the expected number of trials while( trial <= numberOfTrials ) { CrapsGame trialGame = new CrapsGame(); trialGame.play(); //Count wins if (trialGame.playerWins()) numberOfWins++; trial++; } //Calculate & display the percentage of winning games double winPercentage = numberOfWins * 100.0 / numberOfTrials; System.out.println("Win Percentage: " + winPercentage + "% " + numberOfWins + " Wins in " + numberOfTrials + " Trials" ); } }