我正在尝试在控制台中创建一个菜单并让用户选择一个选项,由于某种原因,当我运行应用程序时,它会直接转到其他选项,绕过选项广告。
import java.util.Scanner;
public class UserChoice {
public static void main(String[] args)
{
boolean status = true;
while (status == true)
{
System.out.println("");
System.out.println("MENU");
System.out.println("");
System.out.println("A : String Functions");
System.out.println("B : Simple Arithmetic Functions");
System.out.println("C : Temperature Conversion");
System.out.println("D : Sequences");
System.out.println("E : Exit Application");
System.out.println("");
System.out.println("Please make a selection.");
Scanner keyboard = new Scanner(System.in);
String choice =null;
choice = keyboard.nextLine();
if (choice == "a" || choice == "A")
{
StringFunctions();
}
else if (choice == "b" || choice == "B")
{
ArithmeticFunctions();
}
else if (choice == "c" || choice == "C")
{
TemperatureConversion();
}
else if (choice == "d" || choice == "D")
{
Sequences();
}
else if (choice == "e" || choice == "E")
{
System.exit(0);
}
else
{
System.out.println("You have entered an invalid selection, please choose again.");
}
}
}