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
23 lines (22 loc) · 996 Bytes
/
Copy pathTime.java
File metadata and controls
23 lines (22 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
public class Time {
public static void main(String[] args) {
double hourStart = 16.0;
double minuteStart = 20.0;
double secondStart = 25.0;
System.out.print("Seconds since midnight: " );
double secondsSinceMidnight = hourStart * 3600 + minuteStart * 60 + secondStart;
System.out.println(secondsSinceMidnight);
System.out.print("Seconds remaining in the day: ");
double secondsRemainingInDay = 86400 - secondsSinceMidnight;
System.out.println(secondsRemainingInDay);
System.out.print("Percentage of the day that has passed: ");
double percentageOfDayPassed = secondsSinceMidnight / 86400 * 100;
System.out.println(percentageOfDayPassed);
double hourEnd = 16.0;
double minuteEnd = 50.0;
double secondEnd = 11.0;
System.out.print("Seconds elapsed since I started this exercise: ");
double secondsSinceStart = (hourEnd * 3600 + minuteEnd * 60 + secondEnd) - secondsSinceMidnight;
System.out.println(secondsSinceStart);
}
}