forked from AllenDowney/ThinkJavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTime.java
More file actions
48 lines (24 loc) · 1.17 KB
/
Time.java
File metadata and controls
48 lines (24 loc) · 1.17 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
42
43
44
45
46
47
48
public class Time
{
public static void main(String args[])
{
int hour = 9;
int minute = 12;
int second = 23;
int secondsPerMinute = 60;
int minutesPerHour = 60;
int secondsSinceMidnight = (hour * minutesPerHour * secondsPerMinute) + (minute * secondsPerMinute) + second;
System.out.println("Seconds Since Midnight: " + secondsSinceMidnight);
int hoursPerDay = 24;
int secondsInDay = hoursPerDay * minutesPerHour * secondsPerMinute;
int secondsRemainingInDay = secondsInDay - secondsSinceMidnight;
System.out.println("Seconds Remaining in The Day: " + secondsRemainingInDay);
int percentage = 100 * secondsSinceMidnight / secondsInDay;
System.out.println("Percent of Day that Has Passed: " + percentage);
int currentHour = 10;
int currentMinutes = 24;
int currentSeconds = 38;
System.out.print("Elapsed time of Exercise: " );
System.out.println((currentHour - hour)+":"+(currentMinutes - minute)+":"+(currentSeconds - second));
}
}