I am making a guessing game for fun. For some reason, the code in the for loop never processes. I didvided it into three parts. Please let me knowCan someone help me? I have checked and the code doesnt proceed int the for loop. I am certain there is nothing wrong with the for loop. Thanks for your hwlp Thanks
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Random;
public class Guess {
public static Random r = new Random();
public static BufferedReader in = new BufferedReader(
new InputStreamReader(System.in));
public static final String YES_S = "y";
public static final String NO_S = "n";
public static void main(String [] args) throws IOException {
boolean menu = true;
boolean start = false;
boolean end = false;
boolean ans = true;
boolean rand = true;
int num = -1;
int guessNum = -1;
while(menu) {
System.out.println( "Start game [ y ]:");
String input = in.readLine();
if(input.equals(YES_S)) {
menu = false;
start = true;
end = false;
}
}
while(start) {
while(ans) {
while(rand) {
num = r.nextInt(11);
rand = false;
}
for (int i = 0; i > 3; i++) {
System.out.println( " Guess a number from 0 to 10 :");
String input1 = in.readLine();
guessNum = Integer.parseInt(input1);
if (guessNum == num) {
System.out.println( " Congratulations !");
ans = false;
rand = true;
} else {
System.out.println( " Try again");
}
}
if(ans = true) {
end = true;
}
}
}
}
}