- (2)如果是旺季(4-10月)机票折扣为头等舱9折,经济舱7.5折。淡季头等舱8折,经 济舱6机票打折程序。功能:机票原价为4000rmb(1)输入月份和座舱类型(1为头等舱,2为经济舱)。折。运行结果如图:
package java01;
import java.util.Scanner;
public class Java27 {
public static void main(String[] args) {
Scanner Sc = new Scanner(System.in);
System.out.println("请输入你出行的月份:1~12");
int a = Sc.nextInt();
System.out.println("请问你选择头等舱还是经济舱?头等舱输入1,经济舱输入2");
int b = Sc.nextInt();
double money;
if(a>=4&&a<=10) {
if(b==1) {
money = 0.9;
}else {
money = 0.75;
}
}else {
if(b==1) {
money = 0.8;
}else {
money = 0.6;
}
}
System.out.println("您的机票价格为"+4000*money);
}
}