南航航空公司里程累计计算表
服务等级 | 订座舱位(代号) | 舱位累积比例 |
头等舱 | F,A | 150% |
公务舱 | C,D | 130% |
经济舱 | Y,T,K | 100% |
其他舱位 | M,G | 0 |
package choice.sample;
import java.io.IOException;
import java.util.Scanner;
public class LetMeFly {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
int mznum;
String seats;
char seat,choice;
float newflight1;
double newflight2,flight=0.0;
System.out.println("请输入你的明珠卡号:");
Scanner input1=new Scanner(System.in);
mznum=input1.nextInt();
do{
System.out.println("请输入你的订座舱位:");
Scanner input2=new Scanner(System.in);
seats=input2.next();
seat=seats.charAt(0);
System.out.println("请输入你的本次飞行里程:");
Scanner input3=new Scanner(System.in);
newflight1=input3.nextFloat();
switch(seat){
case 'A':
case 'F':
newflight2=newflight1*1.5;
flight=flight+newflight2;
break;
case 'C':
case 'D':
newflight2=newflight1*1.3;
flight+=newflight2;
break;
case 'Y':
case 'T':
case 'K':
newflight2=newflight1*1;
flight+=newflight2;
break;
case 'M':
case 'G':
newflight2=newflight1*0.4;
flight+=newflight2;
break;
default:
newflight2=0;
flight+=newflight2;
}
System.out.println("还需要继续累积里程吗?请输入Y/N:");
choice=(char)System.in.read();
}while(choice=='Y');
System.out.println("明珠卡号为:"+mznum+"的用户,你好!");
System.out.println("你的本次飞行累积航空里程为:"+flight);
}
}