From 9f432197177a490707f17efed2e4fd30f83f51d5 Mon Sep 17 00:00:00 2001 From: BFristoe Date: Sun, 28 Jan 2024 18:35:56 -0800 Subject: [PATCH] Created program to display current time, seconds to next midnight and from last midnight and the time spend working on this code. --- .idea/misc.xml | 3 ++- .idea/vcs.xml | 6 ++++++ Java-Assignment-002.iml | 1 + src/Time.java | 42 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 .idea/vcs.xml create mode 100644 src/Time.java 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..98aeab6 --- /dev/null +++ b/src/Time.java @@ -0,0 +1,42 @@ +public class Time { + + public static void main(String[] args) { + + int hour; + int minute; + int second; + int pastMidnight; + int secondsInDay; + secondsInDay = 24 * 60 * 60; + hour = 16; + minute = 48; + second = 30; + double seconds = second; + pastMidnight = hour * 60 * 60 + second; + int oldHour; + int oldMinute; + int oldSecond; + oldSecond = second; + oldHour = hour; + oldMinute = minute; + hour = 18; + minute = 17; + second = 12; + System.out.print("The current time is "); + System.out.print(hour); + System.out.print(":"); + System.out.println(minute); + System.out.print("Number of seconds since midnight is "); + System.out.println(pastMidnight); + System.out.print("Number of seconds remaining until midnight is "); + System.out.println(secondsInDay - pastMidnight); + System.out.print("Percent of day completed "); + System.out.println((pastMidnight * 100.0) / secondsInDay); + System.out.println("Total time working on this "); + System.out.print(hour - oldHour); + System.out.print(":"); + System.out.print(minute + 60 - oldMinute); + System.out.print(":"); + System.out.println(second + 60 - oldSecond); + } +} \ No newline at end of file