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
51 changes: 50 additions & 1 deletion src/main/java/Main.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,58 @@
/**
* Created by iyasuwatts on 10/17/17.
*/

public class Main {

public static void main(String[] args){

}
}

*/


/**
* Created by iyasuwatts on 10/17/17.
*/

import java.util.Scanner;

public class Main {

public static void main(String[] args) {

Scanner amy = new Scanner(System.in);
System.out.println("Dear user please choose a number.");
int userNum = amy.nextInt();

System.out.println("Ok. So glad you can follow directions. Would you like to do some addition or some repeated addition? Please type" +
" 'add' for addition and 'repeated add' for repeated addition. NO OTHER ANSWERS WILL BE ACCEPTED.");

amy.nextLine();

String userChoice = amy.nextLine();

int count = 0;

if (userChoice.equalsIgnoreCase("add")) {
count = 0;

// get sum
for (int i = 1; i <= userNum; i++) {
count += i;
}
} else if (userChoice.equalsIgnoreCase("repeated add")) {
count = 1;
// get product
for (int i = 1; i <= userNum; i++) {
count *= i;
}


}
System.out.println(count);

}
}