标签:
public class Compete { public static void main(String[] args) { int mingCi = 3; //名次 if (mingCi == 1) { System.out.println("参加麻省理工大学计算机学院组织1个月夏令营"); } else if (mingCi == 2) { System.out.println("奖励hp笔记本一部"); } else if (mingCi == 3) { System.out.println("奖励移动硬盘一部"); } else { System.out.println("没有任何奖励"); } }}switch (表达式) { case 常量 1: 语句; break; case 常量 2: 语句; break; … default: 语句; break;}
public class Compete2 { public static void main(String[] args) { int mingci = 1; switch (mingci) { case 1: System.out.println("参加麻省理工大学计算机学院组织1个月夏令营"); break; case 2: System.out.println("奖励hp笔记本一部"); break; case 3: System.out.println("奖励移动硬盘一部"); break; default: System.out.println("没有任何奖励"); break; } }}public class Compete3 { public static void main(String[] args) { int mingCi = 1; switch (mingCi) { case 1: System.out.println("参观麻省理工大学计算机学院组织1个月夏令营"); case 2: System.out.println("奖励hp笔记本一部"); case 3: System.out.println("奖励移动硬盘一部"); default: System.out.println("没有任何奖励"); } }}public class WeekDay{ public static void main(String[] args) { String day = "星期一"; switch (day){ case "星期一": System.out.println("星期一:青菜 "); break; case "星期二": System.out.println("星期二:鱼 "); break; case "星期三": System.out.println("星期三:鱼 "); break; case "星期四": System.out.println("星期四:鱼 "); break; case "星期五": System.out.println("星期五:鱼 "); break; default: System.out.println("自助餐 "); break; } }} int mingCi = 1; switch (mingCi){ case 1: System.out.println("参加麻省理工大学组织的1个月夏令营"); case 2: System.out.println("奖励惠普笔记本电脑一部"); case 3: System.out.println("奖励移动硬盘一个"); default: System.out.println("没有任何奖励 "); }int mingCi = 1;switch (mingCi){ case 1: System.out.println("参加麻省理工大学组织的1个月夏令营"); case 2: System.out.println("奖励惠普笔记本电脑一部"); case 2: System.out.println("奖励移动硬盘一个"); default: System.out.println("没有任何奖励 ");}public class case7 { public static void main(String[] args) { String name="zhangsan"; switch (name) { case "lisi": System.out.println("my name is "+name); break; case "zhangsan": System.out.println("My Name is "+name); break; default: break; } }}


public class LoginMenu { /* * 显示我行我素购物管理系统的登录菜单 */ public static void main(String[] args) { System.out.println("\n\t\t欢迎使用我行我素购物管理系统\n"); System.out.println("\t\t\t 1. 登 录 系 统\n"); System.out.println("\t\t\t 2. 退 出\n"); System.out.println("* * * * * * * * * * * * * * * * * * * * * * * * *\n"); System.out.print("请选择,输入数字:"); /* 从键盘获取信息,并执行相应操作---新加代码 */ Scanner input = new Scanner(System.in); int num = input.nextInt(); switch (num) { case 1: /* 显示系统主菜单 */ System.out.println("\n\t\t欢迎使用我行我素购物管理系统\n"); System.out.println("* * * * * * * * * * * * * * * * * * * * * * * * * * \n"); System.out.println("\t\t\t1. 客 户 信 息 管 理\n"); System.out.println("\t\t\t 2. 购 物 结 算\n"); System.out.println("\t\t\t 3. 真 情 回 馈\n"); System.out.println("\t\t\t 4. 注 销\n"); System.out.println("* * * * * * * * * * * * * * * * * * * * * * * * * * * \n"); System.out.print("请选择,输入数字:"); break; case 2: /* 退出系统 */ System.out.println("谢谢您的使用!"); break; default: System.out.println("输入错误。"); break; } }}public class LoginMenu { /* * 显示我行我素购物管理系统的登录菜单 */ public static void main(String[] args) { System.out.println("\n\t\t欢迎使用我行我素购物管理系统\n"); System.out.println("\t\t\t 1. 登 录 系 统\n"); System.out.println("\t\t\t 2. 退 出\n"); System.out.println("* * * * * * * * * * * * * * * * * * * * * * * * *\n"); System.out.print("请选择,输入数字:"); /* 从键盘获取信息,并执行相应操作---新加代码 */ Scanner input = new Scanner(System.in); if(input.hasNextInt()){ int num = input.nextInt(); switch (num) { case 1: /* 显示系统主菜单 */ System.out.println("\n\t\t欢迎使用我行我素购物管理系统\n"); System.out.println("* * * * * * * * * * * * * * * * * * * * * * * * * * \n"); System.out.println("\t\t\t 1. 客 户 信 息 管 理\n"); System.out.println("\t\t\t 2. 购 物 结 算\n"); System.out.println("\t\t\t 3. 真 情 回 馈\n"); System.out.println("\t\t\t 4. 注 销\n"); System.out.println("* * * * * * * * * * * * * * * * * * * * * * * * * * * \n"); System.out.print("请选择,输入数字:"); break; case 2: /* 退出系统 */ System.out.println("谢谢您的使用!"); break; default: System.out.println("输入错误。"); break; } }else { System.out.println("输入错误。"); } }}
public class ConsumeSavePlan { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("请输入消费金额:"); double money = input.nextDouble(); double extra = 0; //换购付款 int choice = 0; //换购项目 if(money>=50){ System.out.println("是否参加优惠换购活动:"); System.out.println("1:满50元,加2元换购百事可乐饮料1瓶"); System.out.println("2:满100元,加3元换购500ml可乐一瓶"); System.out.println("3:满100元,加10元换购5公斤面粉"); System.out.println("4:满200元,加10元可换购1个苏泊尔炒菜锅"); System.out.println("5:满200元,加20元可换购欧莱雅爽肤水一瓶"); System.out.println("0:不换购"); System.out.print("请选择:"); if(input.hasNextInt()==true){ choice = input.nextInt(); switch(choice){ case 1: if(money>=50){ extra = 2; } break; case 2: if(money>=100){ extra = 3; } break; case 3: if(money>=100){ extra = 10; } break; case 4: if(money>=200){ extra = 10; } break; case 5: if(money>200){ extra = 20; } break; default: break; } }else{ System.out.println("请输入正确的数字!"); } } //结账 double total = money + extra; System.out.println("本次消费总金额:"+ total); if(choice == 1){ System.out.println("成功换购:" + "百事可乐饮料1瓶。"); }else if(choice ==2 ){ System.out.println("成功换购:" + "500ml可乐一瓶。"); }else if(choice == 3){ System.out.println("成功换购:" + "5公斤面粉。"); }else if(choice == 4){ System.out.println("成功换购:" + "1个苏泊尔炒菜锅。"); }else if(choice == 5){ System.out.println("成功换购:" + "欧莱雅爽肤水一瓶。"); }else { System.out.println("无换购项目!"); } }}
标签:
原文地址:http://www.cnblogs.com/mentorStudio/p/4635398.html