import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        guessMyNumber(100);
    }
    
    public static void guessMyNumber(int n) {
        // Math.random() return a value in range [0,1)
        // Multiply by 100 and range is [0,100)
        // Truncate by casting at int, and range is [0,99]
        // Add one to make range [1,100]
        int solution = 1 + (int) (n * Math.random());
        // Now pass the max number and solution and play game
        play(n, solution);
    }

    public static void play(int n, int solution) {
        // The solution is non-zero, so initializing the
        // guess to 0 will force the while loop to execute
        // at least once.  Note that this approach makes
        // do...while unnecessary.
        int guess = 0;
        Scanner in = new Scanner(System.in);
        
        while (guess != solution) {
            // get user guess
            System.out.print("Enter a number between 1 and " + n + ": ");
            guess = in.nextInt();
            // give feedback on higher/lower
            if (guess < solution) {
                System.out.println("HIGHER!");
            } else if (guess > solution) {
                System.out.println("LOWER!");                
            }
            // Note that we do not test for == because if
            // the guess matches the solution, the while
            // loop won't be done any more...
        }
        
        System.out.println("You win!");
    }
}