我的程序不工作。你觉得哪里不对?
Scanner in = new Scanner(System.in);
System.out.print("Enter first number: ");
double num1 = in.nextDouble();
System.out.print("Enter second number: ");
double num2 = in.nextDouble();
System.out.println("Enter operation to perform: ");
String oper = in.next();
if(oper == "add" || oper == "addition" || oper == "+") {
double sum = num1 + num2;
System.out.printf("The sum of the two numbers is %d", sum);
}
当我键入操作(这是一个字符串)时,程序终止。输出:
Enter first number: 12
Enter second number: 8
Enter operation to perform:
"add"
Process completed.
我似乎找不到错误,请帮助?