From 6267005cbb07181d929a9db034846c5493ce1fec Mon Sep 17 00:00:00 2001 From: Chloe Christine Fontenot Date: Sun, 19 Oct 2025 21:30:53 -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 zcmbQjI+=~@)W2Q(7#JAr81yD`t%&Dj;9?NwVGv;uWn^H^FD+qY5cSDQEKAhS%-0Vn z%FHVXE-6Y)%(doV5NBjy;9`(ukYZ<$=3$UwkY!{L#-fsufxQ5vFDH+YK~!UM0;32s zJA?ejtwxOXaturiAi%`H$iT|L#=yv+z`($u&%nsQ$iTqBsF0=Dt0rlM{Z)^+|I!7gD`^&Y@q-HH-j{T7=s=IgBVzVhe4V_hJk^Bn}Lx*mO+kz VkwG40KO=)Q0|Nsig96wMiU7B&5K{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 zcmaFPvxtxD)W2Q(7#JAr7!o&fon_<@Vqjs=WM?qhe2dYMQII#dBr!SLH?bfjF)1gN zoxygpB(pc44;O=2$F2SWsylag2ol8FMV%g8S+D%N9U;PK4MOD%HF zNh~f-EoNtko!rf$#S+iRAUAm)vs?xv1Dj8Nes*aAgCc`50}}%XFflMPurjbQFfy1j zFfiydFfuSQFfg!cZD(NI$iTqB#9+q20G4K8;A1dnU|`^ZC}6N)uw-Ch;AF63ux4Na zX=bcuU}4~5U|`rX*`C#)UV>GGL2deM20kz&-I8_r|MwE?A`B{EF%To&l70FA_nR1m z)cbZZXfQBrW6;s;V_nD~u!%uPvu_uJK2(Th0bIxcEF{6&HnV zOpLv67lRQ)J;*qa517F|2x1UnU|^7B;9-zq5MhvIkYZ3^P-IYK&}2|zFknz)uw>9+ zaADA4@MX|rh+r^cNM$f)$YwBMs9-Q-sADi^=w`5Fn8;woFrUGOVJU+x!)68taA?>u zuz`HcV8dX`z`!8IFpI&C!JdJU!JwX@g~5Tro`IP`lcAfzk-?sUl|hkVGJ_L?Jp(%f z55o!uX9gDrP6k)7v)KPL7%;H0Gq^D`Gc&U@urn|S3(E@$3p2QbB7>2^hJk^BnZW}b wA)X9g3=9kk46F>^42%qcU@{m?hJwj(Fewh($ delta 483 zcmZ3)_ne38)W2Q(7#JAr7-BYZon>TZXE5G;pV5(VvN5wKpC=cC7lSuDgAWgb7K88P zF6JYQ{*(P#q%8v(88{dfGV)7{igh>`f*Bdu85L3zD?yx4uvBGgVo|XkBLk0TUS4XE zb53G$acVI;L&W3_ELtp4j0|#<-!qF(KFiEL`40{%D@1YW?_*fQ8LFftf0m^0Wj*fB6OXfoI_I55~TureqzxG^{~*fFp( z@GwL(I59Xga5A`n{LaW=&A`CG%-{<4zZ-))*eDhT4+cgCKQI{pCWF9a2tybH0|OTW NBSSbtBttZVBmnTkNDTl0 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