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..7c74737 --- /dev/null +++ b/src/Time.java @@ -0,0 +1,30 @@ +public class Time { + public static void main(String[] args) { + int currentHour = 16; + int currentMinute = 30; + int currentSecond = 45; + + int secondsSinceMidnight = currentHour * 3600 + currentMinute * 60 + currentSecond; + System.out.println("Seconds since midnight: " + secondsSinceMidnight); + + int totalSecondsInDay = 24 * 3600; + int secondsRemaining = totalSecondsInDay - secondsSinceMidnight; + System.out.println("Seconds remaining in day: " + secondsRemaining); + + double percentagePassed = (secondsSinceMidnight * 100.0) / totalSecondsInDay; + System.out.println("Percentage of the day passed: " + percentagePassed + "%"); +//updating assignment completed times + currentHour = 18; + currentMinute =10; + currentSecond = 30; + + int elapsedTime = (currentHour - 16) * 3600 + (currentMinute - 30) * 60 + (currentSecond - 45); + System.out.println("Time since starting the Assignment: " + elapsedTime + " seconds"); + + int elapsedMinutes = elapsedTime / 60; + int elapsedHours = elapsedMinutes / 60; + elapsedMinutes %= 60; + elapsedTime %= 60; + System.out.println("Total elapsed time: " + elapsedHours + " hours, " + elapsedMinutes + " minutes, " + elapsedTime + " seconds."); + } +}