//The following three lines are needed to get a number from the keyboard.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class TooLow {
	public static void main(String[] args) {

		final int max = 100;
		System.out.println("I am thinking of a number in the range 0 to "
			+ max + " inclusive.");
		System.out.println("Keep trying until you guess it.");
		System.out.println();

		//Let n be a random number in the range 0 to max inclusive.
		final int n = new java.util.Random().nextInt(max + 1);

		int i;

		do {
			System.out.print("Go ahead: ");
			i = getInt();
			if (i < n) {
				System.out.println("Too low.  Try again.");
			} else if (i > n) {
				System.out.println("Too high.  Try again.");
			}

		} while (i != n);

		System.out.println("That's right, the number was " + n + ".");
	}

	//The following 16 lines are needed to get a number from the keyboard.
	private static BufferedReader reader =
		new BufferedReader(new InputStreamReader(System.in));
	private static int getInt() {
		try {
			return Integer.parseInt(reader.readLine());
		}
		catch (IOException e) {
			System.err.println("Couldn't receive input: "
				+ e.getMessage());
		}
		catch (NumberFormatException e) {
			System.err.println(e.getMessage()
				+ ", the characters were not a number.");
		}
		return 0;
	}
}