package case9;
import java.util.Scanner;
public class Price3 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("请输入你出行的月份:1~12");
int month = input.nextInt();
System.out.println("请问你选择的是头等舱还是经济舱?头等舱输入1,经济舱输入2");
if (input.hasNextInt() == true) {
int cabin = input.nextInt();
int oprice = 5000;
if (cabin == 1) {
switch (month / 10) {
case 0:
switch (month) {
case 1:
case 2:
case 3:
System.out.println("你的机票价格为:" + oprice * 0.5);
break;
default:
System.out.println("你的机票价格为:" + oprice * 0.9);
break;
}
default:
switch (month) {
case 10:
System.out.println("你的机票价格为:" + oprice * 0.9);
break;
case 11:
case 12:
System.out.println("你的机票价格为:" + oprice * 0.5);
break;
}
}
}
if (cabin == 2) {
switch (month / 10) {
case 1:
switch (month) {
case 10:
System.out.println("你的机票价格为:" + oprice * 0.8);
break;
default:
System.out.println("你的机票价格为:" + oprice * 0.4);
break;
}
}
switch (month / 10) {
case 0:
switch (month) {
case 1:
case 2:
case 3:
System.out.println("你的机票价格为:" + oprice * 0.4);
break;
default:
System.out.println("你的机票价格为:" + oprice * 0.8);
break;
}
}
}
}
}
}
import java.util.Scanner;
public class Price3 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("请输入你出行的月份:1~12");
int month = input.nextInt();
System.out.println("请问你选择的是头等舱还是经济舱?头等舱输入1,经济舱输入2");
if (input.hasNextInt() == true) {
int cabin = input.nextInt();
int oprice = 5000;
if (cabin == 1) {
switch (month / 10) {
case 0:
switch (month) {
case 1:
case 2:
case 3:
System.out.println("你的机票价格为:" + oprice * 0.5);
break;
default:
System.out.println("你的机票价格为:" + oprice * 0.9);
break;
}
default:
switch (month) {
case 10:
System.out.println("你的机票价格为:" + oprice * 0.9);
break;
case 11:
case 12:
System.out.println("你的机票价格为:" + oprice * 0.5);
break;
}
}
}
if (cabin == 2) {
switch (month / 10) {
case 1:
switch (month) {
case 10:
System.out.println("你的机票价格为:" + oprice * 0.8);
break;
default:
System.out.println("你的机票价格为:" + oprice * 0.4);
break;
}
}
switch (month / 10) {
case 0:
switch (month) {
case 1:
case 2:
case 3:
System.out.println("你的机票价格为:" + oprice * 0.4);
break;
default:
System.out.println("你的机票价格为:" + oprice * 0.8);
break;
}
}
}
}
}
}