Code:
do {
System.out.print("\tMy guess is " + (hi+lo)/2 + ". Is that (l)ow, (h)igh, or (c)orrect? ");
input = IN.readLine();
if ((hi+lo)/2 == hi - 1 || (hi+lo)/2 == 1) {
System.out.println("\tYou are a cheater! You fail at life.");
break; }
input = IN.readLine();
count++;
switch(input.charAt(0)){
case 'l':
lo = (hi + lo) / 2;
break;
case 'h':
hi = (hi + lo) / 2;
break;
case 'c':
System.out.println("\n\tI guessed your number in only " + count + " tries!");
System.out.println("\nThank you for playing Guessing Game.");
break;
}
} while ( ! (input.equals("c") || input.equals("C")) );
for some reason when a question is asked to the user and he/she submits either l,h, or c it need to be entered TWICE before the program does soemthing and goes to asking another questions
IE:
is your number 5? (low high or correct): and then i put in "l"
and then i have to put in "l" again
then it says
is your number 7? (low high or correct):
what is wrong with this?
it seems like a simple mistake