diff --git a/.idea/misc.xml b/.idea/misc.xml index 6e86672..5ad49fe 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..092c139 --- /dev/null +++ b/src/Time.java @@ -0,0 +1,25 @@ +import java.sql.SQLOutput; + +public class Time { + public static void main(String[] args) { + int hour = 10; + int minute = 24; + int seconds = 30; + int totalSecondsInADay = 24 * 60 * 60; + int secondsSinceMidnight = (hour * 3600) + (minute * 60) +seconds; + int secondsRemaining = totalSecondsInADay - secondsSinceMidnight; + double percentageOfDay = (1.0*secondsSinceMidnight/ totalSecondsInADay)*100.0; + minute = 49; + seconds = 15; + int newSecondsSinceMidnight = (hour * 3600) + (minute * 60) +seconds; + int elapSedseconds = newSecondsSinceMidnight - secondsSinceMidnight; + + System.out.printf("Seconds since midnight %d%n", secondsSinceMidnight); + System.out.printf("Seconds remaining in day %d%n", secondsRemaining); + System.out.printf("Percentage of day passed %.2f%%%n", percentageOfDay); + System.out.printf("Elapsed seconds for assignment %d%n", elapSedseconds); + int eSeconds = elapSedseconds % 60; + int eMin = elapSedseconds / 60; + System.out.printf("Elapsed minutes %d and seconds %d%n", eMin, eSeconds); + } +}