import java.util.Scanner;
public class TicketPurchase {
public static void main(String[] args) {
double Ticket=5000.0;
int moth;
System.out.println("请输入您的出行月份:1~12");
Scanner input=new Scanner(System.in);
moth=input.nextInt();
if(moth >= 4 & moth <= 10){
System.out.println("请问您选择头等舱还是经济舱?头等舱输入1,经济舱输入2");
int choose=input.nextInt();
if(choose==1){
System.out.println("您的机票价格为:"+Ticket*0.9+"元");
}else{
System.out.println("您的机票价格为:"+Ticket*0.6+"元");
}
}else{
System.out.println("请问您选择头等舱还是经济舱?头等舱输入1,经济舱输入2");
int choose=input.nextInt();
if(choose==1){
System.out.println("您的机票价格为:"+Ticket*0.5+"元");
}else{
System.out.println("您的机票价格为:"+Ticket*0.4+"元");
}
}
}
}
Java第三章课后练习--订购机票
最新推荐文章于 2022-07-20 16:53:40 发布