diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..9a29b19 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +Time.java \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 639900d..a562d11 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..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 step 2.png b/src/Time step 2.png new file mode 100644 index 0000000..5314c91 Binary files /dev/null and b/src/Time step 2.png differ diff --git a/src/Time step 3.png b/src/Time step 3.png new file mode 100644 index 0000000..3c2b0fc Binary files /dev/null and b/src/Time step 3.png differ diff --git a/src/Time step 4a.png b/src/Time step 4a.png new file mode 100644 index 0000000..2cb99a8 Binary files /dev/null and b/src/Time step 4a.png differ diff --git a/src/Time step 4b.png b/src/Time step 4b.png new file mode 100644 index 0000000..2f6876e Binary files /dev/null and b/src/Time step 4b.png differ diff --git a/src/Time step 5a.png b/src/Time step 5a.png new file mode 100644 index 0000000..78e82c4 Binary files /dev/null and b/src/Time step 5a.png differ diff --git a/src/Time step 5b.png b/src/Time step 5b.png new file mode 100644 index 0000000..2be2c6a Binary files /dev/null and b/src/Time step 5b.png differ diff --git a/src/Time.java b/src/Time.java new file mode 100644 index 0000000..7f2e68f --- /dev/null +++ b/src/Time.java @@ -0,0 +1,42 @@ +public class Time { + //Doing this without help because I believe I can. + //Merged int definitions into 1 line during step 4, code worked great + + public static void main(String [] args) { + // int hour = 17, minute = 43; + // double second = 13.0; + int hour = 13, minute = 57; + double second = 03.0; + 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("."); + // Calculate and display the number of seconds since midnight. + System.out.print("Number of seconds since midnight: "); + System.out.println(hour * 60 * 60 + second); + // Extend the program to calculate and display the number of seconds remaining in the day. + System.out.print("Number of seconds remaining until midnight: "); + System.out.println(24 * 60 * 60 - 46803); + // Calculate and display the percentage of the day that has passed. + // Adding two extra lines for my own references. + System.out.print("Number of seconds in a day: "); + System.out.println(24 * 60 * 60); + System.out.print("Percent of the day that has passed: "); + System.out.println(46803.0 * 100 / 86400); + // Modify the values of hour, minute, and second to reflect the current time. Then, write code to compute the elapsed time since you started working on this exercise. + System.out.println("Seconds from start to midnight: 25187"); + System.out.println("Seconds from midnight to finish: 46803"); + System.out.print("Seconds since beginning of this exercise: "); + System.out.println(46803.0 + 25187); + System.out.print("Minutes since beginning of this exercise: "); + System.out.println(71990.0 / 60); + System.out.print("Hours since beginning of this exercise: "); + System.out.println(1199.8333333333333 / 60); + System.out.print("Percent of a 24 hr period that has passed: "); + System.out.println(71990.0 * 100 / 86400); + //I added a few unnecessary steps, because I'm "getting it" and making use of the practice. + } +} \ No newline at end of file