Code not getting executed. Seeing the "Program ran too long" error
package en.codegym.java.core.level05.task11;
import java.util.Random;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Random rand = new Random();
int secret = rand.nextInt(100) + 1; // 1..100
Scanner console = new Scanner(System.in);
// Game with the spirit
while (true) {
System.out.print("Enter a number (1-100): ");
int guess = console.nextInt();
if (guess < secret) {
System.out.println("Higher!");
} else if (guess > secret) {
System.out.println("Lower!");
} else {
System.out.println("Correct!");
break;
}
}
}
}