From 93b5ba7bbde230b65048a02618d2063e0016d860 Mon Sep 17 00:00:00 2001 From: JMo95 <33079476+JMo95@users.noreply.github.com> Date: Thu, 10 May 2018 13:11:13 -0400 Subject: [PATCH 1/2] Add files via upload My programs I've made so far using Think Java. Also a test of using Github. --- CelciusToFarenheit.java | 4 ++++ Date.java | 24 ++++++++++++++++++++++++ SecondsConverter.java | 22 ++++++++++++++++++++++ Time.java | 29 +++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+) create mode 100644 CelciusToFarenheit.java create mode 100644 Date.java create mode 100644 SecondsConverter.java create mode 100644 Time.java diff --git a/CelciusToFarenheit.java b/CelciusToFarenheit.java new file mode 100644 index 0000000..81cde45 --- /dev/null +++ b/CelciusToFarenheit.java @@ -0,0 +1,4 @@ +import java.util.Scanner; + +public class SecondsConverter{ +} \ No newline at end of file diff --git a/Date.java b/Date.java new file mode 100644 index 0000000..7c0f00d --- /dev/null +++ b/Date.java @@ -0,0 +1,24 @@ +public class Date { + + public static void main(String[] args){ + String day = "Wednesday"; + String month = "May"; + int date = 9; + int year = 2018; + + printAmerican(day,date,month,year); + printEuropean(day,date,month,year); + + } + + public static void printAmerican(String day, int date, String month, int year){ + //prints a date in American format + System.out.println("American format: " + day + ", " + month + " " + date + ", " + year + "."); + } + + public static void printEuropean(String day, int date, String month, int year){ + //prints a date in European format + System.out.println("European format: " + day + " " + date + " " + month + " " + year + "."); + } + +} \ No newline at end of file diff --git a/SecondsConverter.java b/SecondsConverter.java new file mode 100644 index 0000000..f942564 --- /dev/null +++ b/SecondsConverter.java @@ -0,0 +1,22 @@ +import java.util.Scanner; + +/** + * Converts seconds into hours, minutes, seconds + */ +public class SecondsConverter{ + + public static void main(String[] args){ + int seconds; + Scanner in = new Scanner(System.in); + //user inputs amount of seconds + System.out.print("Amount of seconds to convert: "); + seconds = in.nextInt(); + //conversions for seconds into minutes, seconds, hours + final int HOURS = (seconds / 3600); + final int MINUTES_REMAINDER = (seconds % 3600); + final int MINUTES = (MINUTES_REMAINDER / 60); + final int SECONDS = (MINUTES_REMAINDER % 60); + //displays seconds into hours, minutes, seconds + System.out.printf("%d seconds = %d hours, %d minutes, and %d seconds", seconds, HOURS, MINUTES, SECONDS); + } +} diff --git a/Time.java b/Time.java new file mode 100644 index 0000000..14890f3 --- /dev/null +++ b/Time.java @@ -0,0 +1,29 @@ +public class Time { + public static void main(String[] args) { + //time when i started this code + int hour = 2; + int minute = 53; + int second = 12; + //time when i finished this code + int newHour = 3; + int newMinute = 10; + int newSecond = 13; + int secondsPerDay = (24 * 3600); + int secondsSinceMidnight = (hour * 3600) + (minute * 60) + second; + int newSecondsSinceMidnight = (newHour * 3600) + (newMinute * 60) + newSecond; + double secondsPerDayDbl = (24 * 3600); + double secondsSinceMidnightDbl = (hour * 3600) + (minute * 60) + second; + double percentagePassed = (secondsSinceMidnightDbl / secondsPerDayDbl); + + //displays how many seconds have passed since midnight + System.out.println("There have been " + secondsSinceMidnight + " seconds since midnight"); + //displays how many seconds left in a day + System.out.println("There are " + (secondsPerDay - secondsSinceMidnight) + " seconds left in this day."); + //displays the percentage of the day that has passed + System.out.println(percentagePassed + "% of the day has passed."); + //displays time that has passed since I started programming this + System.out.println((newSecondsSinceMidnight - secondsSinceMidnight) + + " seconds have passed since you wrote this code"); + + } +} From 8b3828185a3a6db0334b7f3b4d1408fc43dc333e Mon Sep 17 00:00:00 2001 From: JMo95 <33079476+JMo95@users.noreply.github.com> Date: Thu, 10 May 2018 13:17:11 -0400 Subject: [PATCH 2/2] Delete CelciusToFarenheit Reason: invalid file --- CelciusToFarenheit.java | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 CelciusToFarenheit.java diff --git a/CelciusToFarenheit.java b/CelciusToFarenheit.java deleted file mode 100644 index 81cde45..0000000 --- a/CelciusToFarenheit.java +++ /dev/null @@ -1,4 +0,0 @@ -import java.util.Scanner; - -public class SecondsConverter{ -} \ No newline at end of file