From d02e88324dc4acf120fee19c421fe3fda63d1692 Mon Sep 17 00:00:00 2001 From: Karousha Fennimore Date: Wed, 7 Feb 2018 06:42:15 -0500 Subject: [PATCH 1/5] Almost solved --- src/main/java/Main.java | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/main/java/Main.java b/src/main/java/Main.java index 1dbc0cb..63c4db0 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -1,9 +1,45 @@ /** * Created by iyasuwatts on 10/17/17. */ +import java.util.Scanner; + public class Main { public static void main(String[] args){ + Scanner input = new Scanner(System.in); + + System.out.println("Please enter a number: "); + // 3. Use the Scanner to read a line of text from the user. + String userInput = input.nextLine(); + + System.out.println("Would you like to add or multiply? "); + // 3. Use the Scanner to read a line of text from the user. + String computeInput = input.nextLine(); + + if(computeInput.equalsIgnoreCase("add")) { + + int numInput = Integer.parseInt(userInput); + int sum = 0; + + for (int i = 1; i <= numInput; i++) { + + sum += i; + } + System.out.println(sum); - } + } else if (computeInput.equalsIgnoreCase("multiply")) { + + int numInput = Integer.parseInt(userInput); + int sum = 1; + + for (int i = 1; i <= numInput; i++) { + + sum *= i; + } + System.out.println(sum); + + } + + +} } From f4f28d38976360eb699a92cc8d69d0c2bfefcb0f Mon Sep 17 00:00:00 2001 From: kfennimore <32980838+kfennimore@users.noreply.github.com> Date: Wed, 7 Feb 2018 13:31:13 -0500 Subject: [PATCH 2/5] Update Main.java --- src/main/java/Main.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/Main.java b/src/main/java/Main.java index 63c4db0..eba6dd1 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -9,11 +9,9 @@ public static void main(String[] args){ Scanner input = new Scanner(System.in); System.out.println("Please enter a number: "); - // 3. Use the Scanner to read a line of text from the user. String userInput = input.nextLine(); System.out.println("Would you like to add or multiply? "); - // 3. Use the Scanner to read a line of text from the user. String computeInput = input.nextLine(); if(computeInput.equalsIgnoreCase("add")) { From b99982978e986b2cfe84088332ad4fb2ee030da4 Mon Sep 17 00:00:00 2001 From: Karousha Fennimore Date: Wed, 7 Feb 2018 13:54:35 -0500 Subject: [PATCH 3/5] Updated --- src/main/java/Main.java | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/main/java/Main.java b/src/main/java/Main.java index 63c4db0..c93fa07 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -9,34 +9,26 @@ public static void main(String[] args){ Scanner input = new Scanner(System.in); System.out.println("Please enter a number: "); - // 3. Use the Scanner to read a line of text from the user. - String userInput = input.nextLine(); + int personNum = input.nextInt(); System.out.println("Would you like to add or multiply? "); - // 3. Use the Scanner to read a line of text from the user. - String computeInput = input.nextLine(); + String computeInput = input.next(); if(computeInput.equalsIgnoreCase("add")) { - - int numInput = Integer.parseInt(userInput); int sum = 0; - for (int i = 1; i <= numInput; i++) { - + for (int i = 1; i <= personNum; i++) { sum += i; } - System.out.println(sum); - + System.out.println(sum); } else if (computeInput.equalsIgnoreCase("multiply")) { + int multTotal = 1; - int numInput = Integer.parseInt(userInput); - int sum = 1; - - for (int i = 1; i <= numInput; i++) { + for (int i = 1; i <= personNum; i++) { - sum *= i; + multTotal *= i; } - System.out.println(sum); + System.out.println(multTotal); } From 39d62c8a26d87d1afb04b88044255ed71e5bd769 Mon Sep 17 00:00:00 2001 From: Karousha Fennimore Date: Wed, 7 Feb 2018 13:56:25 -0500 Subject: [PATCH 4/5] Updated --- .DS_Store | Bin 0 -> 6148 bytes src/.DS_Store | Bin 0 -> 6148 bytes src/main/.DS_Store | Bin 0 -> 6148 bytes 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 .DS_Store create mode 100644 src/.DS_Store create mode 100644 src/main/.DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a039083d95e447ce4b9bc63fbb167e92bbfd09d3 GIT binary patch literal 6148 zcmeHK&2G~`5T0#9vk5}vfYhFlFGw5;N<@_&5RyrgLnTlvjNkyMwd1I@WP2mqA+%|b zFMWve20RK+z=QAr@a+$%`9a(eqC3*;H#0l4_I|c^y+p*iGU z{p^kO4*cRIF!oC!;$OBOyo!dC!{(h`krsZG4l`98g+rvgeI2Etm~_QB4RbY)r#m>W z^ZH?Pb2{yGI$O^6c6+wvOm}u#upf11vpV0n*M72hl$@ST&u1SmF%<~I0;}Yv%{$$T_AV6$=D?L;uys1lP)SW5B#p{N{C=xSg+Mz%uYh2ITtS zKqa~cOO0yjK%qUV4VD_w17W%ps7skSVlZ8fxMT8MgQZ4YPRtxW zn7J}DClscxj`1CpPR!M4Tg!lDV4i`BcAIkl@BjY%KVM`$%YbFzzhZz@dtR@LDVe=> yX>xL}b)ZL3DKf9rs7lb7?N}LdE8c`EL7yWHplh(yhzP{~2q+qCV;T6X4EzA)N|UDm literal 0 HcmV?d00001 diff --git a/src/.DS_Store b/src/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..2ac5799baa75bda0f8ebf2a2f7c60c9803a51179 GIT binary patch literal 6148 zcmeHK%}T>S5Z?m>XMpyuD6T~)Vv&B@zb(wIz8NuvjN_ty_r~q>OLUXO-K<)Dm4&I|^vtYM zWmTRpp9WXDA7o+H>o&s9F+J^v*;VB11Fe&>9Y%+7yMI<$+|g+k#%a4_lH*nzAty(1 z+S2`o?xn4+Stqa)N|jXUtg<{9)a&&%Z)2l2T=NE-n^oBB_2ICjmR4%pd*|18_k)Mw z80IQQEM3LRP$TerWB`4KxkY#&{3Bp!;DH(VQwH7vlF3^1 literal 0 HcmV?d00001 diff --git a/src/main/.DS_Store b/src/main/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..53b6321eec2593a9050fc6e1d37ecca6af44e55c GIT binary patch literal 6148 zcmeHKyG{c!5ZonKM50NV(j_f5jTME0IzNyH5)wM)BqUN_m(PaTM-Yick%j_hrS;g} z9a}fWtye^J@&0@-G82(0+)$1-v}SSh#%^-QQ0Nw|zhCU$BdNX;gp;Pys4H1*pIk3S{k^-d@3BDixpt|3d-$KNPrO zO&kOL*MY&F?-uV2%`o?;Kd|JwCXRuKz%;19plY@lnw^6N9r2p^V_?ul{brn#H*0n% znvI7RPZzC$9H{^mI9Fg2%bC^xNB9r@|2c^(DnJGPlmglg#9zXy9 literal 0 HcmV?d00001 From 08ac12fd56d04640f9068641e8fc2fbd83660b54 Mon Sep 17 00:00:00 2001 From: kfennimore <32980838+kfennimore@users.noreply.github.com> Date: Wed, 7 Feb 2018 14:01:34 -0500 Subject: [PATCH 5/5] Update Main.java --- src/main/java/Main.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/main/java/Main.java b/src/main/java/Main.java index db7854b..87f56d6 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -9,17 +9,10 @@ public static void main(String[] args){ Scanner input = new Scanner(System.in); System.out.println("Please enter a number: "); -<<<<<<< HEAD int personNum = input.nextInt(); System.out.println("Would you like to add or multiply? "); String computeInput = input.next(); -======= - String userInput = input.nextLine(); - - System.out.println("Would you like to add or multiply? "); - String computeInput = input.nextLine(); ->>>>>>> f4f28d38976360eb699a92cc8d69d0c2bfefcb0f if(computeInput.equalsIgnoreCase("add")) { int sum = 0; @@ -28,11 +21,11 @@ public static void main(String[] args){ sum += i; } System.out.println(sum); + } else if (computeInput.equalsIgnoreCase("multiply")) { int multTotal = 1; for (int i = 1; i <= personNum; i++) { - multTotal *= i; } System.out.println(multTotal);