From 6f593e47b14291ffc7a8b74bc800f53d0288ae64 Mon Sep 17 00:00:00 2001 From: AlexeiIachkov Date: Sat, 27 Jan 2024 11:23:01 -0800 Subject: [PATCH] Completed Java-Assignment-002 --- .idea/misc.xml | 2 +- .idea/vcs.xml | 6 +++++ Java-Assignment-002.iml | 1 + src/Time.java | 54 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 62 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 639900d..172df7b 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +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..564a7b5 --- /dev/null +++ b/src/Time.java @@ -0,0 +1,54 @@ +/** + * + * @author Trevor Hartman + * @author Alexei Iachkov + * + * @version 1.0 + * + * @date 1-19-24 + * + */ + +public class Time { + + public static void main(String[] args) { + int hour = 13; + int minute = 26; + int second = 30; + + System.out.print("The current time is "); + System.out.print(hour); + System.out.print(":"); + System.out.print(minute); + System.out.print(":"); + System.out.print(second); + System.out.println("."); + + int secondsSinceMidnight = hour * 3600 + minute * 60 + second; + System.out.print("Number of seconds since midnight: "); + System.out.println(secondsSinceMidnight); + + int secondsInDay = 24 * 3600; + int secondsRemainingInDay = secondsInDay - secondsSinceMidnight; + System.out.print("Number of seconds remaining in the day: "); + System.out.println(secondsRemainingInDay); + + int percentDayPassed = 100 * secondsSinceMidnight / secondsInDay; + System.out.print("Percent of the day that has passed: "); + System.out.println(percentDayPassed); + + int updatedHour = 22; + int updatedMinute = 46; + int updatedSecond = 12; + + int updatedSecondsSinceMidnight = updatedHour * 3600 + updatedMinute * 60 + updatedSecond; + int elpasedTime = updatedSecondsSinceMidnight - secondsSinceMidnight; + System.out.print("Number of seconds since start of assignment: "); + System.out.println(elpasedTime); + + + + + } + +}