Question
Problem 1 Ask user to enter time in the format of hh:mm:ss. For example, 11:07:28. Hour must be a two-digit number between 0 and 23,
Problem 1
Ask user to enter time in the format of hh:mm:ss. For example, 11:07:28. Hour must be a two-digit number between 0 and 23, inclusive.Minute and second must be two-digit numbers between 0 and 59, inclusive.The program needs to check whether the time entered is valid.
(a)Check whether there are exactly two colons. Display an error message and stop if the input is invalid.
(b) Check whether hour is a two-digit number. Display an error message and stop if the input is invalid.
(c)Check whether minute is a two-digit number. Display an error message and stop if the input is invalid.
(d) Check whether second is a two-digit number. Display an error message and stop if the input is invalid.
(e)Check whether hour is between 0 and 23, inclusive. Display an error message and stop if the input is invalid.
(f)Check whether minute is between 0 and 59, inclusive. Display an error message and stop if the input is invalid.
(g) Check whether second is between 0 and 59, inclusive. Display an error message and stop if the input is invalid.
(h) If the time entered is valid, remove the colons and display the time.For example, if the input time is 11:07:28, the program should display 110728.
The following are a few examples:
Enter time [hh:mm:ss]: 10.44.58
Must separate hour, minute and second with colons.
Enter time [hh:mm:ss]: 11:27 28
Must separate hour, minute and second with colons.
Enter time [hh:mm:ss]: 11:16:ss
Second must be a 2-digit number.
Enter time [hh:mm:ss]: 15:4:26
Minute must be a 2-digit number.
Enter time [hh:mm:ss]: 24:05:07
Hour must be a 2-digit number between 0 and 23.
Enter time [hh:mm:ss]: 14:07:28
Time with colons removed: 140728
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