import java.util.*; public class PickThreeGame2 { public static void main(String[] args) { Random generator = new Random(); Scanner in=new Scanner(System.in); int amount=5000, wager, g1, g2, g3, num1, num2, num3, payoff; System.out.println("Let's Play Pick 3 Lotto. You start with $" + amount); System.out.println("You get 500 times your bet if you match all 3 numbers in the right order."); System.out.println("You get 167 times your bet if you match all 3 numbers in any order."); System.out.println("You get 100 times your bet if you match 2 of the 3 numbers in the right order."); System.out.println("You get 25 times your bet if you match 2 of the 3 numbers with one number in the right order."); do { System.out.print("You currently have $" + amount + ", how much do you want to wager? "); wager=in.nextInt(); }while(wager>amount||wager<1); while(wager>0) { System.out.print("Pick your first number (0-5): "); g1=in.nextInt(); System.out.print("Pick your second number (0-5): "); g2=in.nextInt(); System.out.print("Pick your third number (0-5): "); g3=in.nextInt(); num1=generator.nextInt(6); num2=generator.nextInt(6); num3=generator.nextInt(6); System.out.println("The Lotto numbers are: " + num1 + ", " + num2 + ", and " + num3); if(g1==num1&&g2==num2&&g3==num3) { payoff=wager*500; System.out.println("You win on a straight bet, your payoff is $" + payoff + ", Congratulations!"); } else if((g1==num2&&g2==num3&&g3==num1)||(g1==num2&&g2==num1&&g3==num3)|| (g1==num3&&g2==num2&&g3==num1)||(g1==num3&&g2==num1&&g3==num2)||(g1==num1&&g2==num3&&g3==num2)) { payoff=wager*167; System.out.println("You got the three numbers, but not in the right order, your payoff is $" + payoff + ", Congratulations!"); } else if((g1==num1&&g2==num2)||(g1==num1&&g3==num3)||(g2==num2&&g3==num3)) { payoff=wager*100; System.out.println("You matched two of three numbers in the right order, your payoff is $" + payoff + ", Congratulations!"); } else if((g1==num1&&g2==num3)||(g1==num1&&g3==num2)||(g2==num2&&g3==num1)||(g2==num2&&g1==num3)||(g3==num3&&g1==num2)||(g3==num3&&g2==num1)) { payoff=wager*25; System.out.println("You matched two of three numbers, with one number in the right order, your payoff is $" + payoff + ", Congratulations!"); } else { payoff=0; System.out.println("I'm sorry, you lose your $" + wager + " bet."); } amount+=payoff-wager; do { System.out.print("You currently have $" + amount + ", how much do you want to wager? "); wager=in.nextInt(); }while(wager>amount||wager<0); } System.out.println("Thanks for playing! You have $" + amount + " left."); } }