1. 程式人生 > >程式設計實現: 李四去海南旅遊定機票,機票的價格受淡季和旺季影響,受頭等艙和經濟艙影響。 假設機

程式設計實現: 李四去海南旅遊定機票,機票的價格受淡季和旺季影響,受頭等艙和經濟艙影響。 假設機

public class Test_17 {
public static void main(String[] args) {


Scanner input = new Scanner(System.in);
System.out.println("請輸入您出行的月份:");
int month = input.nextInt();
System.out.println("請問您選擇頭等艙還是經濟艙?頭等艙輸入1,經濟艙輸入2");
int type = input.nextInt();
double price = 5000.0;
if (month==1 || month==2 || month==3 || month==11 || month==12) {
if (type==1) {
price*=0.5;
}else if (type==2) {
price*=0.4;
}
} else {
if (type==1) {
price*=0.9;
} else if (type==2) {
price*=0.8;
}
}
System.out.println("您的機票價格為:"+price);


}


}