Instruction: We will write a program that reads in a time in the 24-hour military time format, check for its validity, and if it's valid, output the time in the corresponding 12-hour am-pm block time. Please name your source code as timecheck.cpp.
Your program works as follows:
A time is valid if the hour is between 0 and 24, and the minute is between 0 and 59, and the second is between 0 and 59.
Please review Military Time Chart to see how to convert military time to 12-hour am-pm clock time.
An example run of your program is as follows, where the user inputs are underlined, and the program output are shown in regular format:
$ ./a.out Please enter a time in military format (HH:MM:SS):11:32:30 It's a valid time! In 12-hour am-pm clock, this is 11:32:30 am. Bye!An example when the time entered is in the PM:
$ ./a.out Please enter a time in military format (HH:MM:SS):14:30:30 It's a valid time! In 12-hour am-pm clock, this is 2:30:30 pm. Bye!An example when the time entered is in midnight:
$ ./a.out Please enter a time in military format (HH:MM:SS):24:42:40 It's a valid time! In 12-hour am-pm clock, this is 12:42:40 midnight. Bye!The following example shows a run when the input is wrong:
$ ./a.out Please enter a time in military format (HH:MM:SS):25:32:30 It's invalid! The hours must be between 0 and 24. Bye!The following example shows a run when the min is wrong:
$ ./a.out Please enter a time in military format (HH:MM:SS):25:-9:30 It's invalid! The minutes must be between 0 and 59. Bye!Yet another example when the input is wrong:
$ ./a.out Please enter a time in military format (HH:MM:SS):24:32:67 It's invalid! The second must be between 0 and 59. Bye!Coding Style Requirement:
How to submit
Please submit your program (which has to be named timecheck.cpp) to the following webpage: Lab3 submission link.
Please refer to Lab Instruction 4 here for how to 1) transfer your code from storm to your laptop, and then 2) submit your code to autograder.