Question
program to do the following.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
program to do the following.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.
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