java-第四章-机票价格受到淡季旺季的影响,编写的小程序
时间:2014-06-01 16:40:54
收藏:0
阅读:507
import java.util.Scanner; public class A02 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner (System.in); System.out.println("请输入月份:1~12"); int choice=input.nextInt(); System.out.println("请问您是选择头等舱还是经济舱?头等舱输入1,经济舱输入2."); int choice1=input.nextInt(); double money=0; if(choice>=4&&choice<=10){ switch (choice1) { case 1: money=5000*0.9; break; case 2: money=5000*0.8; break; default: System.out.println("输入有误!"); break; } }else{ switch (choice1) { case 1: money=5000*0.5; break; case 2: money=5000*0.4; break; default: System.out.println("输入有误!"); break; } } System.out.println("您的机票价格为:"+money); } }
评论(0)