Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedimage text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

3rd Edition

0471418455, 978-0471418450

More Books

Students also viewed these Databases questions

Question

Compare the different types of employee separation actions.

Answered: 1 week ago

Question

Assess alternative dispute resolution methods.

Answered: 1 week ago

Question

Distinguish between intrinsic and extrinsic rewards.

Answered: 1 week ago