Difference of times

Report a typo

Find how many seconds passed between the two moments of time on the same day.

Three integer values are used to represent a moment of time. The first integer represents hours, the second integer gives the minutes, and finally the third one gives seconds.

Write a program that takes six integer input for two moments of time and calculates the difference between these two moments. Print the result in seconds.

Input data format

The program gets the input of six integers representing two different moments of time. It is guaranteed that the earlier moment is provided as the first three integers. The next three integers represent the next moment in time.

For example, six numbers 1, 2, 30, 15, 21, 1 will represent two moments of time: 1:02:30 am and 3:21:01 pm (or just 15:21:01). Notice that the second moment represents a time that comes after the first one.

Output data format

Just one number: seconds between these two moments of time. It's 51511 (14 hours, 18 minutes and 31 seconds) for the example given above.

Hint

Each hour has 60 minutes, and each minute has 60 seconds. So an hour has a total of 60 * 60 seconds = 3,600 seconds.

Sample Input 1:

1
1
1
2
2
2

Sample Output 1:

3661

Sample Input 2:

1
2
30
1
3
20

Sample Output 2:

50
Write a program in Java 17
import java.util.Scanner;

class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// put your code here
}
}

Create a free account to access the full topic