0
これは私の割り当てのためのもので、曜日を入力するようユーザーに求め、コストを表示します。私はチケットの価格の総額を計算するために視聴者の番号を尋ねることにより、ユーザーからより多くの情報を入手したいと考えています。これは私のコードです。視聴者とチケットの価格を計算する
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();
}
}
}
私はこれがあなたの問題を解決する必要があります理解してできるだけ多くの
を望んでいたそして、あなたはどのような問題に直面しているものであれば教えてください? –
私は質問が何であるか混乱しています。また、toLowerCase()を使用して、日を複製しないようにしてください。 – kinezu
その問題ではありません。私は総額を計算して追加情報を追加したいと思います。 –