From b54c9636de0c216bfed83620c2bce3b935a0c80d Mon Sep 17 00:00:00 2001 From: tpedersen42 Date: Fri, 26 Jan 2024 14:11:39 -0800 Subject: [PATCH] Done with Assignment 002 --- .idea/misc.xml | 3 ++- .idea/vcs.xml | 6 ++++++ Java-Assignment-002.iml | 1 + src/Time.java | 26 ++++++++++++++++++++++++++ 4 files changed, 35 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..69ace3f 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..8dffa83 --- /dev/null +++ b/src/Time.java @@ -0,0 +1,26 @@ +public class Time { + public static void main(String[] args) { + String time = "Number of seconds from midnight: "; + int hour = 13; + int minute = 25; + int second = 30; + //calculate # of seconds in 13 hours and 25 minutes plus 30 seconds + int secondsSinceMidnight =(hour * 3600) + (minute * 60) + second; + //print total seconds since midnight + System.out.println(time + secondsSinceMidnight + " seconds"); + //calculate seconds in a day = 24 hour*60 minute* 60 seconds + int secondsInADay = 24 * 60 * 60; + int secondsRemaining = secondsInADay -secondsSinceMidnight; + System.out.println( "Seconds remaining in the day: " + secondsRemaining + " seconds"); + // calculate percentage of day that has passed + double percantageOfDay = ((double) secondsSinceMidnight / secondsInADay) * 100; + System.out.println("Percentage of the day that has passed: " + percantageOfDay + "%"); + // calculate time that elapsed while working on this exercise + int newHour = 14; + int newMinute = 4; + int newSecond = 15; + //calculate seconds + int newSecondsSinceMidnight =(newHour * 3600) + (newMinute * 60) + newSecond; + System.out.println("Seconds elapsed since start: " + (newSecondsSinceMidnight - secondsSinceMidnight) + " seconds"); + } +} \ No newline at end of file