为什么算出来是850而不是900?
问题相关代码,请勿粘贴截图
**package com.xiaogao.plane;
import java.util.Scanner;
public class Demo {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入机票的原价:");
double money = sc.nextDouble();
System.out.println("请输入月份(1-12):");
int month = sc.nextInt();
System.out.println("请输入头等舱还是经济舱:");
String type = sc.next();
System.out.println("您的票价是:" + cals(money, month, type));
}
public static double cals(double money, int month, String type) {
if (month >=5 && month <= 10) {
if (type == "头等舱") {
money *= 0.9;
return money;
} else {
money *= 0.85;
return money;
}
}
else {
if (type == "头等舱") {
money = 0.7;
return money;
} else {
money = 0.65;
return money;
}
}
}
}