public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter your guess: "); int input = in.nextInt(); int comp = (int)(Math.random()*100) + 1; if(input < comp) { System.out.println("Too low"); } else if(input > comp) { System.out.println("Too High"); } else { System.out.println("Congratulations"); } System.out.println("The random number was: " + comp); }
The user is supposed to keep on guessing the number if he doesn't get it correct, but my code doesn't let the person continue to guess.