I have a program here that requires a user to enter a guess from 1-100 and then tells the user whether he/she went to high or to low. I'm very new to
JAVA and trying to figure all this stuff out..heres a copy of the program.
The program comes up with no compiler errors, but when i enter the guess the program freezes on me and doesnt go with the loop..any suggestions?
import java.util.*;
import java.io.*;
import javax.swing.JOptionPane;
public class guess
{
static BufferedReader keyboard =
new BufferedReader(new InputStreamReader(System.in));
public static void main(
String[] args) throws IOException
{
int guess;
int randomnumber;
int number;
int count = 0;
randomnumber = (int)( Math.random() * 100 + 1);
guess = randomnumber;
System.out.print("Please enter in your guess: ");
System.out.flush();
number = Integer.parseInt(keyboard.readLine());
System.out.println();
while(number != guess);
{
count = count + 1;
if(number > guess)
System.out.print("Your number was too large, try again");
else
System.out.print("Your number was too small, try again");
System.out.print("Please enter in your guess: ");
System.out.flush();
number = Integer.parseInt(keyboard.readLine());
System.out.println();
}
System.out.println("It took you " + count + "guesses");
}
}