Skip to content

Commit fe66b43

Browse files
committed
Create Time
1 parent 88477ee commit fe66b43

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

ch02/Time

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
public class Time {
2+
public static void main(String[] args) {
3+
double hour;
4+
double minute;
5+
double second;
6+
hour = 19.0;
7+
minute = 44.0;
8+
second = 40.0;
9+
System.out.println("Number of seconds since midnight:");
10+
System.out.println((hour * 60) * 60 + (minute * 60) + second);
11+
double secondsSinceMidnight;
12+
secondsSinceMidnight = ((hour * 60) * 60 + (minute * 60) + second);
13+
System.out.println("Number of seconds remaining in the day:");
14+
int secondsInTheDay;
15+
secondsInTheDay = ((24 * 60) * 60);
16+
System.out.println(secondsInTheDay - secondsSinceMidnight);
17+
System.out.println("Percentage of the day that has passed:");
18+
System.out.println((secondsSinceMidnight * 100) / secondsInTheDay);
19+
System.out.println("Time elapsed since I started working on this (seconds)");
20+
System.out.println(secondsSinceMidnight - 69630);
21+
22+
}
23+
}

0 commit comments

Comments
 (0)