how do i make this so once the user inputs a number and presses enter(or something) it runs the if else statements! please help!
public static void main(String[] args) {
System.out.println("please guess the number between 1 and 100.");
boolean run = true;
int y = 0;
Random ran = new Random();
int x = ran.nextInt(99);
while (run == true) {
Scanner scan = new Scanner(System.in).useDelimiter(" ");
// System.out.println(scan.nextInt());
y = scan.nextInt();
/*
* if(y > 0){ run = false; } else{ run = true; }
*/
if (y > x) {
System.out.println("Lower...");
} else if (y < x) {
System.out.println("Higher...");
} else if (y == x) {
System.out.println("Correct!");
try {
Thread.currentThread().sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.exit(0);
}
}
}
}