求大神幫我看下這個問題在哪
package lianXi;
import java.util.Scanner;
public class Travel {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
// 出行月份
System.out.println("請輸入您出行的月份:1~12");
int month = input.nextInt();
// 乘坐是經(jīng)濟艙還是頭等艙
System.out.println("請問您選擇頭等艙還是經(jīng)濟艙?頭等艙輸1,經(jīng)濟艙輸2");
int plane = input.nextInt();
// 旺季出行還是淡季出行
int money = 5000;
// 旺季出行
if ((month>=4) && (month <= 10)) {
// 乘坐頭等艙
if ("1".equals(plane)) {
double num1 = money * 0.9;
System.out.println("您的機票價格為:" + num1);
} else
{
// 乘坐二等艙
double num2 = money * 0.8;
System.out.println("您的機票價格為:" + num2);
}
} else {
// 淡季出行
if ((month>=1) && (month <= 3)||month==11||month==12) {
// 乘坐頭等艙
if ("1".equals(plane)) {
double num3 = money * 0.5;
System.out.println("您的機票價格為:" + num3);
} else
// 乘坐二等艙
{
double num4 = money * 0.4;
System.out.println("您的機票價格為:" + num4);
}
}
}
}
}
2017-03-14
.equals 只能用做字符串對比 ? int不行
2017-03-13
要用else if ?語句,另外寫全其他兩種情況的成立條件