0

I was making a program for a simple guessing game (user thinks of a number and computer tries to guess). I ran into a problem when executing this while loop. The while loop appears to run infinitely asking "Please retype" even if I enter "l" "h" or a "c".

public static void play() {
    inputBounds();
    while((ub-lb) < 20 || lb<=0) {
        System.out.println("Upper bound – lower bound must be >= 20. ");
        inputBounds();
    }
    int guess = gen.nextInt((ub-lb) + 1) + lb;
    System.out.println("I guess, the answer is " + guess);
    System.out.print("Your answer is (h=higher than you thought, l=lower than you thought, c=correct):");
    String hint = input.next();
    while(!hint.equalsIgnoreCase("l") || !hint.equalsIgnoreCase("h") || !hint.equalsIgnoreCase("c")) {
        System.out.print("Please retype.");
        hint = input.next();
    }

}

0 Answers0