if和switch语句的嵌套使用

public class Exercise5 {
public static void main(String[] args) {
System.out.println("-------欢迎来到明日饭店-------");
System.out.println("主菜单 > 查询今日特价菜");
System.out.println("请输入您的性别:");
Scanner scanner = new Scanner(System.in);
String sex = scanner.next();
System.out.println("请输入您要查询的日期:");
Scanner scanner2 = new Scanner(System.in);
String week = scanner2.next();
if (sex.equals("男")){

switch (week){
case "周一":
System.out.println("男生星期一特价菜: 红烧猪肘,15元一份");
break;
case "周二":
System.out.println("男生星期二特价菜: 鱼香肉丝,25元一份");
break;
case "周三":
System.out.println("男生星期三特价菜: 木须肉,55元一份");
break;
case "周四":
System.out.println("男生星期四特价菜: 红烧丸子,10元一份");
break;
case "周五":
System.out.println("男生星期五特价菜: 酸辣土豆丝,60元一份");
break;
case "周六":
System.out.println("男生星期六特价菜: 豆角烧茄子,50元一份");
break;
case "周日":
System.out.println("男生星期日特价菜: 溜肉段,85元一份");
break;
}
}else if (sex.equals("女")){
switch (week){
case "周一":
System.out.println("女生星期一特价菜: 麻辣小龙虾,15元一份");
break;
case "周二":
System.out.println("女生星期二特价菜: 烤鱿鱼,25元一份");
break;
case "周三":
System.out.println("女生星期三特价菜:尖椒肉丝,55元一份");
break;
case "周四":
System.out.println("女生星期四特价菜: 红烧鲤鱼,10元一份");
break;
case "周五":
System.out.println("女生星期五特价菜: 酸辣黄瓜,60元一份");
break;
case "周六":
System.out.println("女生星期六特价菜: 豆角焖面,50元一份");
break;
case "周日":
System.out.println("女生星期日特价菜: 大四喜,85元一份");
break;
}
}
}
}

if和switch语句的嵌套使用_第1张图片

 

你可能感兴趣的:(java,开发语言)