import java.util.Scanner;
public class yanfengshan1 {
public static void main(String[]args){
Scanner input=new Scanner(System.in);
System.out.println("请输入您出行的月份:");
int month=input.nextInt();
if(month>=4&&month<=10){System.out.println("你出行的月份是旺季");}
else{System.out.println("你出行的月份是淡季");}
System.out.println("您选择头等舱还是经济舱出行?头等舱请按1,经济舱请按2");
int choice=input.nextInt();
if(choice==1){System.out.println("您选择使用头等舱出行");}
if(choice==2){System.out.println("您选择使用经济舱出行");}
if(choice!=1&&choice!=2){System.out.println("请输入正确的选项");}
double money=5000*0.5;
if(month>=1&&month<=3||month>=11&&month<=12&&choice==1){System.out.println("您的机票价格是:"+money);}//头等舱淡季价格
double money2=5000*0.9;
if(month>=4&&month<=10&&choice==1){System.out.println("您的机票价格是:"+money2);}//头等舱旺季
double money3=5000*0.4;
if(month>=1&&month<=3||month>=11&&month<=12&&choice==2){System.out.println("您的机票价格是:"+money3);}//经济舱淡季
double money4=5000*0.8;
if(month>=4&&month<=10&&choice==2){System.out.println("您的机票价格是:"+money4);}//经济舱旺季
}
}
为毛我选淡季,总是会出来两个价格。搞不懂。
public class yanfengshan1 {
public static void main(String[]args){
Scanner input=new Scanner(System.in);
System.out.println("请输入您出行的月份:");
int month=input.nextInt();
if(month>=4&&month<=10){System.out.println("你出行的月份是旺季");}
else{System.out.println("你出行的月份是淡季");}
System.out.println("您选择头等舱还是经济舱出行?头等舱请按1,经济舱请按2");
int choice=input.nextInt();
if(choice==1){System.out.println("您选择使用头等舱出行");}
if(choice==2){System.out.println("您选择使用经济舱出行");}
if(choice!=1&&choice!=2){System.out.println("请输入正确的选项");}
double money=5000*0.5;
if(month>=1&&month<=3||month>=11&&month<=12&&choice==1){System.out.println("您的机票价格是:"+money);}//头等舱淡季价格
double money2=5000*0.9;
if(month>=4&&month<=10&&choice==1){System.out.println("您的机票价格是:"+money2);}//头等舱旺季
double money3=5000*0.4;
if(month>=1&&month<=3||month>=11&&month<=12&&choice==2){System.out.println("您的机票价格是:"+money3);}//经济舱淡季
double money4=5000*0.8;

if(month>=4&&month<=10&&choice==2){System.out.println("您的机票价格是:"+money4);}//经济舱旺季
}
}
为毛我选淡季,总是会出来两个价格。搞不懂。