Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Java-Assignment-002.iml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
34 changes: 34 additions & 0 deletions src/Time.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
public class Time {
public static void main(String[] args) {
String firstLine = "Hello, again!";
System.out.println(firstLine);

int hour = 19;
int minute = 10;
int seconds = 18;
System.out.println("The current time is " + hour + ":" + minute + ":" + seconds + ".");

int secondsSinceMidnight = hour * 3600 + minute * 60 + seconds;
System.out.println("Seconds since midnight: " + secondsSinceMidnight);

int secondsInADay = 24 * 3600;
int secondsRemaining = secondsInADay - secondsSinceMidnight;
System.out.println("Seconds remaining in the day: " + secondsRemaining);

double percentPassed = (secondsSinceMidnight * 100.0) / secondsInADay;
System.out.println("Percentage of the day passed: " + percentPassed + "%");

int currentHour = 20;
int currentMinute = 17;
int currentSecond = 15;
int elapsedTime = ((currentHour - hour) * 3600) + ((currentMinute - minute) * 60) + (currentSecond - seconds);
System.out.println("Elapsed time since starting this exercise: " + elapsedTime + " seconds");

int elapsedMinutes = elapsedTime / 60;
int elapsedHours = elapsedMinutes / 60;
elapsedMinutes %= 60;
elapsedTime %= 60;
System.out.println("Total time elapsed: " + elapsedHours + " hours, " + elapsedMinutes + " minutes, " + elapsedTime + " seconds. ");
}

}