-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtime.java
More file actions
41 lines (29 loc) · 1.15 KB
/
time.java
File metadata and controls
41 lines (29 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import java.util.Scanner;
public class time
{
/* Program that reads values representing a time duration in hours, minutes,
and seconds, and then prints the equivalent total number of seconds.
1 minute = 60 seconds
1 hour = 60 minute
60 minute = 3600 seconds
*/
public static void main(String[] args)
{
int hour;
int minutes;
int second;
int total_seconds;
Scanner myHour = new Scanner(System.in);
System.out.println("Enter Hour");
hour = myHour.nextInt();
Scanner myMinutes = new Scanner(System.in);
System.out.println("Enter minutes");
minutes = myMinutes.nextInt();
Scanner mySecond = new Scanner(System.in);
System.out.println("Enter Seconds");
second = mySecond.nextInt();
total_seconds = (hour * 3600) + (minutes * 60) + second;
System.out.println(hour +"hour" + minutes+"minutes" + second + "seconds");
System.out.println("Travel Time" + total_seconds + " seconds");
}
}