import java.util.Random;
import java.util.Scanner;
class indexerad_variable
{
public static void main(String[] args)
{
Random generator = new Random();
Scanner scan = new Scanner(System.in);
int Tries=0;
int number = generator.nextInt(100) + 1;
String igen;
while(true)
{
System.out.print("\nNumber 1 - 100: ");
Tries++;
int guess = scan.nextInt();
if(guess < number)
{
System.out.println("to low");
}
if(guess > number)
{
System.out.println("to high");
}
if(guess == number)
{
System.out.println("Right you have tried "+Tries+" ");
{
}
System.out.print("\nPlay again y/n: ");
igen = scan.next();
if (igen.equalsIgnoreCase("N"))
break;
}
}
}
}
the program works fine until im going to press y and it return to the last game i dont understan what i need to do for it to work. can anyone help me?