Question: Write a program that reads a week date and outputs its day, hours, and minutes. The program should start by printing the following message: Enter

 Write a program that reads a week date and outputs its

Write a program that reads a week date and outputs its day, hours, and minutes. The program should start by printing the following message: Enter a date: The user must enter, on a new line, a day of the week ("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", and "Sun") and a time (as HH:MM am/pm). For example: Mon 1:00 pm At this point, the program must print on the screen the following message: Day: D Hour: HH Minute: MM Where: D is the day number (1 = Mon, 7 = Sun); HH is the number of hours in 24-hour format (as a two-digit integer, with a leading O if less than 10); MM is the number of minutes (as a two-digit integer, with a leading 0 if less than 10). For example, the above inputs will produce: Day: 1 Hour: 13 Minute: 00 Hints 1. You can use a switch statement to convert the string with the day of the week into an integer; 2. The string method String.endsWith(String suffix) could be particularly helpful to check if an input refers to an a.m. or p.m. hour; 3. If x is a two-digit integer, then System.out.printf("%02d", x) will print a leading O when x

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!