java计算观众数量和票价
这是我的作业,它要求用户输入一周中的一天,并显示成本。我想通过询问观众人数,从用户那里获得更多信息,以便计算门票的总定价金额。这是我的密码
Scanner keyboard = new Scanner(System.in);
// Prompt user to enter the day of the week
System.out.println("Please enter the day of the week:");
day = keyboard.nextLine();
switch (day){
// User can input the days in different ways and the cost will be printed
case "Monday":
case "monday":
case "MONDAY":
System.out.println("The cost of the movie ticket is RM 5.");
break;
case "Tuesday":
case "tuesday":
case "TUESDAY":
System.out.println("The cost of the movie ticket is RM 5.");
break;
case "Wednesday":
case "wednesday":
case "WEDNESDAY":
System.out.println("The cost of the movie ticket is RM 5.");
break;
case "Thursday":
case "thursday":
case "THURSDAY":
System.out.println("The cost of the movie ticket is RM 10.");
break;
case "Friday":
case "friday":
case "FRIDAY":
System.out.println("The cost of the movie ticket is RM 20.");
break;
case "Saturday":
case "saturday":
case "SATURDAY":
System.out.println("The cost of the movie ticket is RM 30.");
break;
case "Sunday":
case "sunday":
case "SUNDAY":
System.out.println("The cost of the movie ticket is RM 20.");
break;
default:
System.out.println("Please make sure you made the correct input.");
keyboard.close();
}
}
}
# 1 楼答案
据我所知,这应该是解决你问题的办法
请告诉我这是不是你想要的