diff --git a/.idea/misc.xml b/.idea/misc.xml index 6e86672..172df7b 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,5 +1,6 @@ + - + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Java-Assignment-002.iml b/Java-Assignment-002.iml index b46c0dd..e1006ff 100644 --- a/Java-Assignment-002.iml +++ b/Java-Assignment-002.iml @@ -5,6 +5,7 @@ + \ No newline at end of file diff --git a/src/Time.java b/src/Time.java new file mode 100644 index 0000000..51afe8c --- /dev/null +++ b/src/Time.java @@ -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. "); + } + +} \ No newline at end of file