Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,44 @@
/**
* Created by iyasuwatts on 10/17/17.
*/

import java.util.Scanner;


public class Main {

public static void main(String[] args){
// comment comment


public static void main(String[] args) {

Scanner scan = new Scanner(System.in);
Scanner secondScan = new Scanner(System.in);

System.out.println("Input a number");
int input = scan.nextInt();
int sumTotal = 0;
int productTotal = 1;

System.out.println("Would you like the sum or product of " + input + "?");
String userInput = secondScan.nextLine();

if (userInput.equalsIgnoreCase("sum")) {
for (int i = 0; i <= input; i++) {
sumTotal += i;
}
System.out.println("The sum of your number is " + sumTotal);

} else if (userInput.equalsIgnoreCase("product")) {
for (int i = 1; i <= input; i++) {
productTotal *= i;

}
System.out.println("The product of your number is " + productTotal);
} else {
System.out.println("Invalid command, try again");
}
}
}


}