From 527ffc37aea998361e3f551c7fb40911f3d6544b Mon Sep 17 00:00:00 2001 From: jcheong641 Date: Sun, 28 Jan 2024 22:31:42 -0800 Subject: [PATCH] Completed Assignment 02 --- .idea/vcs.xml | 6 ++++++ Java-Assignment-002.iml | 1 + src/Time.java | 30 ++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 .idea/vcs.xml create mode 100644 src/Time.java 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..8ad7c06 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..ded3583 --- /dev/null +++ b/src/Time.java @@ -0,0 +1,30 @@ +public class Time { + + public static void main(String[] args) { + int hour = 21; + int minute = 10; + int second = 30; + + int secondsPerHour = 3600; + + int secondsSinceMidnight = hour * secondsPerHour + minute * 60 + second; + System.out.println("Seconds since midnight: " + secondsSinceMidnight); + + int secondsInADay = 24 * secondsPerHour; + int secondsRemaining = secondsInADay - secondsSinceMidnight; + System.out.println("Seconds remaining in the day: " + secondsRemaining); + + float percentageOfDayPassed = (float) secondsSinceMidnight / secondsInADay * 100; + System.out.println("Percentage of day passed: " + percentageOfDayPassed + "%"); + + int hourStart = 22; + int minuteStart = 27; + int secondStart = 53; + + int elapsedTime = (hour - hourStart) * secondsPerHour + (minute - minuteStart) * 60 + (second - secondStart); + System.out.println("elapsed time since started working: " + elapsedTime + " seconds"); + + System.out.println("Time"); + } + +} \ No newline at end of file