Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

In Java programming,thanks Write a program to Ask the user to enter a time in military time (24 hours). The input must be entered in

In Java programming,thanks image text in transcribed
Write a program to Ask the user to enter a time in military time (24 hours). The input must be entered in military format (xx:xx). The program will convert and display the equivalent conventional time (12 hour with AM or PM) for each entry if it is a valid military time. An error message will be printed if the entry is not a valid military time. Thinlk about how you would convert any military time between 00:00 and 23:59 into conventional time. Also think about what would be valid military times To be a valid time, the data must have a specific form. First, it should have exactly 5 characters. Next, only digits are allowed in the first two and last two positions, and that a colon is always used in the middle position. Next, we need to ensure that we never have over 23 hours or 59 minutes. When converting from military time to conventional time, we only have to worry about times that have hours greater tharn 12, and we do not need to do anything with the minutes at all. Keep in mind that 00:00 in military time is 12:00 AM (midnight) and 12:00 in military time is 12:00 PM (noon) Test out your program using the following valid input 00:00, 12:00, 04:05, 10:15, 23:59, 00:35 and the following invalid input 7:56, 15:78, 08:60, 24:00, 3e:33, 1:111

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions