package 专题练习;
import java.util.Scanner;
public class sellplaneticket {
public static void main(String[] args) {
String plane_type = type_plane();
plane_judgements(plane_type);
}
public static int month_po(int month){
if(month > 12){
return -1;
}
return 1;
}
public static void plane_judgements(String plane_type) {
if (plane_type.equals("经济舱") ) {
economics();
} else if(plane_type.equals("头等舱")){
First();
}else{
System.out.println("无此舱型");
}
}
public static String type_plane() {
System.out.println("录入舱型:");
Scanner k = new Scanner(System.in);
String cabin_type = k.next();
return cabin_type;
}
public static void First() {
int month = month_in();
if(month_po(month) == -1) {
System.out.println("月份错误");
return;
}
double oldprice = oldrice_in();
if (low_high_seasons(month).equals("旺季")) {
System.out.println("头等舱旺季票价为:" + First_Class_Peak_Season(oldprice));
} else {
System.out.println("头等舱淡季票价为:" + First_Class_Off_Season(oldprice));
}
}
public static void economics() {
int month = month_in();
if(month_po(month) == -1) {
System.out.println("月份错误");
return;
}
double oldprice = oldrice_in();
if (low_high_seasons(month).equals("旺季")) {
System.out.println("经济舱旺季票价为:" + Economy_Class_Peak_Season(oldprice));
} else {
System.out.println("经济舱淡季票价为:" + Economy_Class_Off_Season(oldprice));
}
}
public static int month_in() {
System.out.println("录入月份:");
Scanner k = new Scanner(System.in);
int month = k.nextInt();
return month;
}
public static double oldrice_in() {
System.out.println("录入原票价:");
Scanner k = new Scanner(System.in);
double oldprice = k.nextInt();
return oldprice;
}
public static String low_high_seasons(int month) {
if (month >= 1 && month <= 4 || month >= 11 && month <= 12) {
return "淡季";
} else if(month >= 5 && month <= 10) {
return "旺季";
}
else
return "输入错误";
}
public static double Economy_Class_Peak_Season(double oldprice) {
return oldprice * 0.85;
}
public static double Economy_Class_Off_Season(double oldprice) {
return oldprice * 0.65;
}
public static double First_Class_Peak_Season(double oldprice) {
return oldprice * 0.9;
}
public static double First_Class_Off_Season(double oldprice) {
return oldprice * 0.7;
}
}