Hi everybody - need some help with this code. Been trying to create a simple gussing number game and wrote out this code but can't see what the problem is as there are some errors can someone help?
// This program asks the user to enter a value between 1 and 20.
// If the value entered by the user matches the previoslt random value generated
// by the program then the program displays how many goes the user had.
// Otherwise it reports if its is higher or lower. When the user guesses correctly the program
// asks the user if she or he wishes to continue by typing yes or no.
/**
* Sample output:
* Enter a guess:
* 12
* guess lower
* Enter a guess:
* 6
* correct with 2 guesses
* Do you want to play again (Y,N)?
* Y
* Enter a guess:
* 1
* guess higher
* Enter a guess:
* 12
* guess higher
* Enter a guess:
* 18
* correct with 3 guesses
* Do you want to play again (Y,N)?
* n
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int number;
int turns;
String s;
char playAgain;
Random Generator = new Random;
do
{
number = Generator.nextInt(20)+1;
turns = 0;
int guess = 0;
while ( guess != number )
{
System.out.println("Enter a guess: ");
guess = Easyln.getInt();
turns = turns + 1;
if ( guess == number )
System.out.println("correct with " + turns + "guesses");
else if ( guess < number)
System.out.println ("guess higher");
else
System.out.println("guess lower");
}
System.out.print("Do you want to play again (Y,N)?");
s = Easyln.getString();
playAgain = s.charAt(0);
while ( playAgain == 'n' && playAgain == 'N' )
}
}
}