Question: Write a program called hw2_2.cpp (or hw2_2.java) that reads two timestamps of two events from a user and displays the difference between the two timestamps.

Write a program called hw2_2.cpp (or hw2_2.java) that reads two timestamps of two events from a user and displays the difference between the two timestamps. For the program, you can assume that each timestamp is composed of the hour (0 ~ 23), minute (0 ~ 59), and second (0 ~ 59) format. Your program should present the difference from the second event (= second timestamp) to the first event (= first timestamp). Note that the second event always happens after the first event and your program should display the time difference of the events.

Sample Run 0: Assume that the user typed the following two lines.

18:45:30

20:50:59

This is the correct output of your program.

02:05:29

Sample Run 1: Assume that the user typed the following two lines.

20:18:59

04:25:17

This is the correct output of your program.

08:06:18

Sample Run 2: Assume that the user typed the following two lines.

02:00:25

15:30:00

This is the correct output of your program.

13:29:35

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!