chargerz43
Knight
So I'm not good with loops in Java. This loop keeps repeating itself into an infinite loop. Any tips on how to fix it?
Once again I'm not good with Java so don't judge
Once again I'm not good with Java so don't judge
Code:
import java.util.Scanner;
public class NumberGuess
{
public static void main(String[] args)
{
System.out.println("Think of a whole number(1-100)");
int range = 100;
int min = 0;
int max = 100;
int average;
int number;
int x = 0;
int guess;
while (x 0);
{
max = guess;
guess = (min + max) / 2
System.out.print("Is your number... " + guess );
System.out.print("?");
System.out.println("1) Yes");
System.out.println("2) No");
int choice = reader.nextInt();
switch(choice)
{
case 1: x = 1;
break;
case 2: x = 0;
break;
default:
System.out.println("Wat?");
break;
}
}
System.out.print("I win! Your number is ");
System.out.print(guess);
System.out.println("!");
}
}
}