import java.util.Scanner;
public class tutorial {
public static void main(String[] args) {
/*机票价格按照淡季旺季,头等舱和经济舱收费,输入机票原价,月份和头等舱
* 或经济舱。按照如下规划计算机票价格:旺季(5-10月)头等舱9折,经济舱
* 8折,淡季(11月到来年4月),头等舱7折,经济舱6.5折。
*/
//分析:
//1,键盘录入机票原价,月份,头等舱或经济舱
double v0,v1;
Scanner sc = new Scanner(System.in);
System.out.println("Please enter the original ticket price");
int ticket = sc.nextInt();
System.out.println("Please enter the month");
int month = sc.nextInt();
System.out.println("Please enter first class v0 and economy class v1");
int seat = sc.nextInt();
//2,先判断月份是淡季还是旺季
if(month>=5&&month<=10) {
//旺季:先判断当前机票是头等舱还是经济舱
ticket = getPrice(ticket,seat, v0=0.9, v1=0.85);
}else if((month >=1&& month<=4)||(month>=11&&month<=12)) {
//淡季
ticket = getPrice(ticket,seat, v0=0.7, v1=0.65);
}else {
//表示键盘录入的是一个非法数据
System.out.println("The month of keyboard entry is not legal");
}
System.out.println(ticket);
}
public static int getPrice(int ticket,int seat,double v0,double v1) {
if(seat == 0) {
//头等舱
ticket = (int)(ticket*v0);
}else if(seat==1) {
//经济舱
ticket = (int)(ticket*v1);
}else {
System.out.println("no seat");
}
return ticket;
}
}