The while loop and if statement work through the first iteration. After it completes and it prints "Do you want another time?" and I input "Y" the program terminates and I don't know why. My logic and syntax seem to be correct but there is always flaws that I cant see with my own eyes. I would appreciate it if someone can point the flaw out.
while (!check) {
str = in.nextLine();
if (in.hasNextLine() && str.equals("Y")) {
hours = ran.nextInt(11) + 1;
minutes = ran.nextInt(60);
if (minutes < 10) {
System.out.println(hours + ":" + "0" + minutes);
} else {
System.out.println(hours + ":" + minutes);
}
System.out.println("Do you want another time?");
} else {
check = true;
}
}
Aucun commentaire:
Enregistrer un commentaire