Question: Exercise 3 Filename: seconds.cpp 1. Write a function called NumOfSeconds that takes in three integer parameters (representing hours, minutes, and seconds) and returns the number
Exercise 3
Filename: seconds.cpp
1. Write a function called NumOfSeconds that takes in three integer parameters (representing hours, minutes, and seconds) and returns the number of seconds since the last time the clock "struck 12" (i.e. was at 12:00:00 -- AM or PM doesn't matter since you're not tracking this). NO user input or output to the screen should occur in this function.
2. To test this function, write a main() routine (in the same file) that prompts the user to enter hours, minutes, and seconds for two different clock times; then uses the Seconds function to calculate the shortest amount of time in seconds between the two times (both of which are within one 12-hour cycle of the clock); the print out the number of seconds since "striking 12" for both clocks, as well as the number of seconds between the two clock times
Sample Run 1:
(user input underlined)
Input first clock time... Hours: 6 Minutes: 45 Seconds: 30 Input second clock time... Hours: 4 Minutes: 50 Seconds: 12 There have been 24330 seconds since the 1st clock hit 12:00 There have been 17412 seconds since the 2nd clock hit 12:00 The two times are 6918 seconds apart.
Sample Run 2:
(user input underlined)
Input first clock time... Hours: 12 Minutes: 43 Seconds: 16 Input second clock time... Hours: 7 Minutes: 11 Seconds: 59 There have been 2596 seconds since the 1st clock hit 12:00 There have been 25919 seconds since the 2nd clock hit 12:00 The two times are 23323 seconds apart.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
