package Test;
import java.util.Scanner;
public class Test1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入您的座位类型: ");
String ty = sc.next();
System.out.println("请输入你的航班月份(1-12): ");
int mon = sc.nextInt();
System.out.println("请输入你的机票价格: ");
double pri = sc.nextDouble();
System.out.println(calcu(ty,mon,pri));
}
public static double calcu(String type,int month,double price){
if (type == "经济舱"){
if(month >= 5 && month <= 10){
price *= 0.85;
}
else if (month == 12 ||month == 11 || month >=1 && month <= 4){
price *= 0.65;
}
else {
System.out.println("无效月份"
求助为什么不能进入if else if 线
最新推荐文章于 2024-05-16 10:23:10 发布