For some reason I cannot get it so when I put in a incorrect answer it only prints one 'wrong' message instead of three. I checked other threads but found none. I would appreciate a solution thanks.
public class GuessLetter {
public static void main(String args[])
throws java.io.IOException {
char ch, answer = 'k';
int loop = -1;
System.out.println("I'm thinking of a letter between A and Z.");
System.out.println("Can you guess it: ");
while (loop < 0) {
ch = (char) System.in.read();
if (ch == answer) {
loop++;
System.out.println("**CORRECT**");
} else
System.out.println("Wrong");
}
}
}