I'm trying to make a simple "store" program with a prompt to exit the program at the end. If the user types yes, it will exit. But if they say no, it's supposed to just print a message to let them know they can keep shopping. For some reason that message doesn't appear though. Here is the object.
public class HelloShopper1 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Hello Shopper, what is your name?\n");
String input = scanner.nextLine();
if(!input.matches("[a-zA-Z_]+")) {
System.out.println("Nice try " + input + " . Get out of my store!");
} else {
System.out.println("Thank you, " + input + ". It is my pleasure to help you today.");
System.out.println("Do you want to close this program?");
String input1 = scanner.nextLine();
System.out.println(input1);
if(input1 == "yes") {
System.exit(0);
if(input1 == "no") {
System.out.println("Thank god. Please continue shopping.");
}
}
}
}