package test.dyihe1;
import java.util.Scanner;
public class Day03test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入机票原价");
int ticket = sc.nextInt();
System.out.println("请输入月份");
int month = sc.nextInt();
System.out.println("请输入头等舱或者经济舱 0 表示头等舱 1 表示经济舱");
int seat = sc.nextInt();
if (month >= 5 && month <= 10) {
//旺季
extracted(ticket, seat, 0.9, 0.85);
} else if ((month >= 1 && month <= 4) || (month >= 11 && month <= 12)) {
extracted(ticket, seat, 0.7, 0.65);
} else {
System.out.println("月份非法数据");
}
}
private static void extracted(int ticket, int seat, double v, double v2) {
if (seat == 0) {
System.out.println("当前价格" + ticket * v);
} else if (seat == 1) {
System.out.println("当前价格" + ticket * v2);
}
}
}
Java购买飞机票
最新推荐文章于 2024-11-12 21:14:07 发布