1234567891011121314151617181920212223242526272829 |
- /**
- * Created by iyasuwatts on 10/17/17.
- */
-
- import java.util.Scanner;
-
- public class Main {
-
- public static void main(String[] args){
- Scanner s = new Scanner(System.in);
-
- System.out.println("Welcome to a super fun and simple adder!");
- System.out.print("Please type an integer: ");
- int value = s.nextInt();
- int sum = getSum(value);
- System.out.println("Your sum is " + sum);
- System.out.println("Thanks for using this super fun adder!");
-
- }
-
- private static int getSum(int value){
- int sum = 0;
- for (int i = 1; i <= value; i++) {
- sum += i;
- }
- return sum;
- }
- }
|