It's my first assignment in my Java class and I'm already frustrated lol. Brand new rookie here.
I want to make it so I can input LAX or SAN or LAS and it will move on and list the other statements under my if statement. Instead, it always goes straight to what is under the else statement, even if I do input "LAX" in the console for example.
Here is what I have:
import java.util.Scanner;
public class MilesCalculator {
public static void main(String[] args) {
String airCode = "";
System.out.println("\t\t\tMiles Calculator\n");
System.out.println("This program will calculate how many miles you earn on your Phoenix Air Flight.\n");
System.out.println("DESTINATIONS");
System.out.println("Los Angeles (LAX)");
System.out.println("San Diego (SAN)");
System.out.println("Las Vegas (LAS)\n");
Scanner scnr = new Scanner(System.in);
System.out.print("Please enter the destination airport code: ");
airCode = scnr.nextLine();
if (airCode == "LAX" || airCode == "SAN" || airCode == "LAS") {
System.out.println("STATUS");
System.out.println("1. Bronze");
System.out.println("2. Silver");
System.out.println("3. Gold");
System.out.println("4. Platinum\n");
System.out.print("Please enter your frequent flyer status option (1-4): ");
}
else {
System.out.printf("Phoenix Air does not fly to %s. There will be zero miles earned. \nPress enter to quit...", airCode);
System.exit(0);
scnr.nextLine();
}