import java.util.Scanner;
public class StudySession {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String inData;
int age;
System.out.println("Enter your age");
while(true) {
inData = in.nextLine();
if(inData == "STOP") {
System.out.println("Terminated");
break;
}
age = Integer.parseInt(inData);
if(age < 5) {
System.out.println("Under 5's rate.");
}
if(age >= 60) {
System.out.println("Senior citizen rate.");
}
if(age <= 17) {
System.out.println("Child rate.");
}
if(age > 17 && age < 65) {
System.out.println("Adult rate.");
}
System.out.println("Enjoy the show!"); //This prints no matter what.
}
}
}
I want the program to stop when the user types "STOP". Why is it not working? You don't have to give me a straight up answer. A clue will do. Perhaps it's something to do with the order of my statements?