I'm getting this error SlotMachine1.java:40: while expected } ^ SlotMachine1.java:44: illegal start of expression } ^ SlotMachine1.java:44: reached end of file while parsing } ^ SlotMachine1.java:45: reached end of file while parsing This is my code import java.util.Random; import java.util.Scanner; public class SlotMachine { public static void main (String[] args) { int num1, num2, num3; Random generator = new Random(); num1 = generator.nextInt(9) +1; num2 = generator.nextInt(9) +1; num3 = generator.nextInt(9) +1; Scanner keyboard = new Scanner(System.in); do { System.out.println(+num1 +"|" +num2 +"|" +num3); if (num == num2 && num2 == num3) System.out.println("YOU WIN ALL 3 NUMBERS ARE SAME!"); else if (num1 == num2 || num2 == num3) System.out.println ("2 NUMBERS ARE THE SAME."); else if (num1 != num2 || num1 != num2 || num2 != num3) System.out.println("NONE OF THE NUMBERS ARE THE SAME"); } } }
you can't just use "do" alone you need a while loop, or you need to add "while" at the end of your do loop. read this for more info: http://download.oracle.com/javase/tutorial/java/nutsandbolts/while.html