From 3d1407d1d2de4ceee0c6b8267bee59df54972ca3 Mon Sep 17 00:00:00 2001 From: Daniel Horowitz Date: Wed, 7 Feb 2018 16:30:33 -0500 Subject: [PATCH] product lab --- src/main/java/Main.java | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/main/java/Main.java b/src/main/java/Main.java index 1dbc0cb..81bd61f 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -1,9 +1,31 @@ /** * Created by iyasuwatts on 10/17/17. */ + +import java.util.Scanner; + public class Main { - public static void main(String[] args){ + public static void main(String[] args) { + Scanner in = new Scanner(System.in); + System.out.println("Type your number here fool:"); + int n = in.nextInt(); + Scanner scan = new Scanner(System.in); + System.out.println("Do you want sum or product of your number?"); + String operator = scan.nextLine(); + if (operator.equalsIgnoreCase("sum")) { + int hold = 0; + for (int x = 0; x <= n; x++) { + hold = hold + x; + } + System.out.println("The sum of your number is: " + hold); + } else if (operator.equalsIgnoreCase("product")) { + int fall = 1; + for (int y = 1; y <= n; y++) { + fall = fall * y; + } + System.out.println("The product of your number is: " + fall); + } } }