From 05389258ab81e4edfaf2e210eff58c1f0764935c Mon Sep 17 00:00:00 2001 From: Caleb Fontenot Date: Sat, 27 Aug 2022 13:08:48 -0500 Subject: [PATCH] Work some more on CompoundValue.java --- .../mp1_calebfontenot/CompoundValue.java | 3 +- .../mp1_calebfontenot/NumberOfYears.java | 42 +++++++++++++----- .../target/classes/.netbeans_automatic_build | 0 .../mp1_calebfontenot/CompoundValue.class | Bin 660 -> 787 bytes .../mp1_calebfontenot/NumberOfYears.class | Bin 1639 -> 1826 bytes .../test-classes/.netbeans_automatic_build | 0 6 files changed, 32 insertions(+), 13 deletions(-) create mode 100644 MP1_CalebFontenot/target/classes/.netbeans_automatic_build create mode 100644 MP1_CalebFontenot/target/test-classes/.netbeans_automatic_build 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 f15c54e9c9ba60f0267b72f6280bd3923144815c..46fa95fc76e15956fe22425a322b34210a80d0e9 100644 GIT binary patch delta 313 zcmZvWOHRU27=^z}Ew!bJp`|Lm5ET(0O&n_C3K)<$a-x65AxpE_xmSs#?iC)dgH`TmxjWEuzNJMXkX4Yx<=+en&a>XOt30) delta 202 zcmYL@xedZV6hzI46hR6EmO!EaibBkqfaHzlAM^hy zI$QVtJYK+t+0k9XnEHKg*5*(nP!-W&iNuE7N@}Ebkz=k!yD9oMlxd0CZ-6!(xr8n~ xh4|$yAtgWYB;Mahaw@xjhAR$MN$D$RiQqrTWCzkzu|r1USk4-ik(r1A(=WHG5K{mE 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 de563f15397ee9e9140bde4dc84fd3b765b9bb96..b000d2910de5bfaad21272b0f6e6b1a9a895877b 100644 GIT binary patch delta 697 zcmX|9OHUI~7(JKi^p;6&>?5Wnii0soo2FF7N6}IdUkLaBRD3(=1W2)MW@rL2u^V?J zP0TEen)phLZV{tN7p`29@CW<@F8v4MnOn7sbHDF==X-X3hTlbujo+{Xm^ z%oQZLPl)Ynw$KNBK{nmg-(owdG^zf-RN&2jDzB)d-h7TIRWw@I-{#~$PLex-hF{L# zK!d-*Bof3Fr{76y7rJ2b2t7z+5Ax{cE`2zKEdQb$W|(gCKxGVInc0uI_bL@nx$A2j z$9oj9juYw{L%a<)CR^m&g%|uLO1x0MfhUxd*gnnVVOl!dc{oW+a*U4{VZ%%X7LVgB!@6L3f01*<4vgYFUz7F5*yystDTP-QUQ-yoj+>Mjl-$A{ H+(YUQfvt6w delta 483 zcmYLFyG{a86r9WMy0~sAjEM+Fu~Lx0D!%ZsiugiAe7~R}0ktrgu(6=Bx3Jki@C!r} zO(?9aO!x*%3k!e17>6}#v2)I3&Y3fJZ#-|h_VQJK0$?Iv(;7lj5xajC31P>ilqaQO z6=@Y~Izq_USJJb{+F98j-xP3*!0Gu##R|KzEue}(u~2Q2T}P^x3Kc6Npr^{^QYCp- zu&k1$;=sO@L-LV8kNqKa+6_syKV>~X3>PDSD4?K)I6@X>6|73=5u)bEqr|2RcrZrP ze+Dp)39?qiF-eo=@;hW`tS5F+F)r`W-hW-k0Puh?iB~0y{xOBj_+>$oA&30mjG&EP zUf%Pg1KseU7kvmINHl0W!!FH#bcjJ5BkW`|nUwc2h3P6AA2J*>8Q5UlS#}baOw939 zXtRU_JC!GLm`9S2S>To;xDSpl5?vfxcC2Kq&}iMk4F|Uz+`%4ojoLo5