Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started