using namespace std
int main()
{
float price
cout<<"输入原价:"<<endl
cin>>price
switch((int)price/1000)
{
case 5:price *=0.8break
case 4:
case 3:price *=0.85break
case 2:price *=0.9break
case 1:price *=0.95break
case 0:break
default:price *=0.8
}
cout<<"优惠价:"<<price<<endl
return 0
}
double p1=1000//头等舱double p2=500//经济舱
double p3=0.0//票价
System.out.print("请输入您出行的月份:")
Scanner scan = new Scanner(System.in)
int a = scan.nextInt()
if(a==0&&a>12){
System.out.print("只能输入1-12月份:")
}else{
System.out.print("选择机舱头等舱1经济舱2:")
Scanner sc = new Scanner(System.in)
int aa = sc.nextInt()
if(aa!=0&&aa<3){
if(aa!=1)p3=p2else p3=p1
if(a>=4&&a<=10) p3=p3*0.5else p3=p3*0.4
System.out.println("票价为:"+p3)
}else{
System.out.print("只能输入1或2:")
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)