diff --git a/MP1_CalebFontenot/src/main/java/com/calebfontenot/mp1_calebfontenot/CompoundValue.java b/MP1_CalebFontenot/src/main/java/com/calebfontenot/mp1_calebfontenot/CompoundValue.java index 1297d48..60f37cc 100644 --- a/MP1_CalebFontenot/src/main/java/com/calebfontenot/mp1_calebfontenot/CompoundValue.java +++ b/MP1_CalebFontenot/src/main/java/com/calebfontenot/mp1_calebfontenot/CompoundValue.java @@ -18,9 +18,8 @@ public class CompoundValue { // Define vars double SavingAmount; - // Prompt for input - + System.out.println(""); // Compute // Print result diff --git a/MP1_CalebFontenot/src/main/java/com/calebfontenot/mp1_calebfontenot/NumberOfYears.java b/MP1_CalebFontenot/src/main/java/com/calebfontenot/mp1_calebfontenot/NumberOfYears.java index 4ea1afa..6f50727 100644 --- a/MP1_CalebFontenot/src/main/java/com/calebfontenot/mp1_calebfontenot/NumberOfYears.java +++ b/MP1_CalebFontenot/src/main/java/com/calebfontenot/mp1_calebfontenot/NumberOfYears.java @@ -12,6 +12,7 @@ import java.util.Scanner; * @author caleb */ public class NumberOfYears { + public static void main(String[] args) { // Define vars @@ -19,27 +20,46 @@ public class NumberOfYears { double NumberOfYears; double NumberOfDays; double NumberOfHours; - + // Create Scanner Scanner input = new Scanner(System.in); - + // Prompt for input System.out.print("Enter the number of minutes: "); NumberOfMinutes = input.nextDouble(); - + // Calculate NumberOfHours = (NumberOfMinutes / 60); NumberOfDays = (NumberOfHours / 24); NumberOfYears = (NumberOfDays / 365); - + // Big brain math time - // Check if double "NumberOfYears" equals int "NumberOfYears" - //If it isn't, subtract 365 from "NumberOfDays" until the number is under 365 - + //Subtract 365 from "NumberOfDays" until the number is less than or equal to 365 + while (NumberOfDays >= 365.0) { + //System.out.println("DEBUG: Subtracting 365 from "+ NumberOfDays); + NumberOfDays = NumberOfDays - 365; + } + + // Do the same with hours + while (NumberOfHours >= 24.0) { + //System.out.println("DEBUG: Subtracting 24 from "+ NumberOfHours); + NumberOfHours = NumberOfHours - 24; + } + // Print output - System.out.println((int) NumberOfMinutes+" minutes is approx. :"); - System.out.println((int) NumberOfHours+" hours,"); - System.out.println((int) NumberOfDays+" days,"); - System.out.println((int) NumberOfYears+" years."); + System.out.println((int) NumberOfMinutes + " minutes is approx. :"); + if ((int)NumberOfYears >= 2) { + System.out.println((int) NumberOfYears + " years,"); + } + if ((int)NumberOfYears == 1) { + System.out.println((int)NumberOfYears+" year."); + } + if ((int) NumberOfDays != 0) { + System.out.println((int) NumberOfDays + " days,"); + } + if ((int) NumberOfHours != 0) { + System.out.println((int) NumberOfHours + " hours."); + } + } } diff --git a/MP1_CalebFontenot/target/classes/.netbeans_automatic_build b/MP1_CalebFontenot/target/classes/.netbeans_automatic_build new file mode 100644 index 0000000..e69de29 diff --git a/MP1_CalebFontenot/target/classes/com/calebfontenot/mp1_calebfontenot/CompoundValue.class b/MP1_CalebFontenot/target/classes/com/calebfontenot/mp1_calebfontenot/CompoundValue.class index f15c54e..46fa95f 100644 Binary files a/MP1_CalebFontenot/target/classes/com/calebfontenot/mp1_calebfontenot/CompoundValue.class and b/MP1_CalebFontenot/target/classes/com/calebfontenot/mp1_calebfontenot/CompoundValue.class differ diff --git a/MP1_CalebFontenot/target/classes/com/calebfontenot/mp1_calebfontenot/NumberOfYears.class b/MP1_CalebFontenot/target/classes/com/calebfontenot/mp1_calebfontenot/NumberOfYears.class index de563f1..b000d29 100644 Binary files a/MP1_CalebFontenot/target/classes/com/calebfontenot/mp1_calebfontenot/NumberOfYears.class and b/MP1_CalebFontenot/target/classes/com/calebfontenot/mp1_calebfontenot/NumberOfYears.class differ diff --git a/MP1_CalebFontenot/target/test-classes/.netbeans_automatic_build b/MP1_CalebFontenot/target/test-classes/.netbeans_automatic_build new file mode 100644 index 0000000..e69de29