I have a Java assignment and cannot get it to work.
I am doing a guessing game between 1-100. When I run my code it keeps telling me "too low" whether it is correct or too high.
Here is my code:
public static void main(String[] args) throws java.io.IOException {
int i, ignore, answer = 64;
do {
System.out.println("I'm thinking of a number between 1 and 100.");
System.out.println("Can you guess it?");
i = (int) System.in.read();
do {
ignore = (int) System.in.read();
} while (ignore != '\n');
if (i == answer) System.out.println("**RIGHT**");
else {
System.out.print("...Sorry, you're ");
if (i < answer)
System.out.println("too low");
else
System.out.println("too high");
System.out.println("Try again!\n");
}
} while(answer != i);
}