Question: Relation between 2 4 - hour notation and 1 2 - hour notation is shown in the following table. Let mm be minutes. From the
Relation between hour notation and hour notation is shown in the following table. Let mm be minutes.
From the above table, we notice the processing of hour format can be categorized by four categories,
depending on the value of hour. Each category is represented by different color.
In Task A input time in hour notation and print out the corresponding hour notation. There are several
steps.
Name your source code converttocpp
Input time in hour notation to a string variable.
Extract values of hour and minute from input.
a Use find method of string class to find out the index of colon a character separating hour and
minute.
b Use substr method of string class to get the substring representing hour and minute.
c Use stoi function to convert a string to the corresponding integers. For example, stoi returns
If hour is not in that is hour is smaller than or hour is larger than or minute is not in
then print "invalid input" and return The word "invalid" cannot be missed.
Depending on the values of hour, print out the corresponding hour notation.
Here are some sample inputoutput
a When hour or minute is not valid.
in c with explanation
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
