First of all I am new to this site, but anyways, here is my problem. In my if then statement, I type in "Gen" and it works, but if I type "Launch nuke" or "launch nuke" or "Who am I?" it just ends up saying "Unknown Command" which means it doesn't match any of the statements (or whatever it's called). I tried using == as well but they both don't work. Of course I type Gen first and the Launch nuke after. Here is the code:
import java.util.Scanner;
public class testing {
public static void main(String[] args) {
String alpha;
String bravo;
String charlie;
Scanner input = new Scanner(System.in);
System.out.print("Please confirm identity: ");
alpha = input.next();
if (alpha.equals("Gen")) {
System.out.println("Hello General");
System.out.println("Identity Confirmed");
System.out.print("Please input command: ");
bravo = input.next();
if (bravo.equals("Launch nuke")) {
System.out.println("Launching Missiles");
}
else if (bravo.equals("launch nuke")) {
System.out.println("Launching Missiles");
}
else if (bravo.equals("Who am I?")) {
System.out.print("You are the General");
}
else
System.out.print("Unknown Command");
}
else
System.out.println("Access Denied");
}
}