Main.java 690B

1234567891011121314151617181920212223242526272829
  1. /**
  2. * Created by iyasuwatts on 10/17/17.
  3. */
  4. import java.util.Scanner;
  5. public class Main {
  6. public static void main(String[] args){
  7. Scanner s = new Scanner(System.in);
  8. System.out.println("Welcome to a super fun and simple adder!");
  9. System.out.print("Please type an integer: ");
  10. int value = s.nextInt();
  11. int sum = getSum(value);
  12. System.out.println("Your sum is " + sum);
  13. System.out.println("Thanks for using this super fun adder!");
  14. }
  15. private static int getSum(int value){
  16. int sum = 0;
  17. for (int i = 1; i <= value; i++) {
  18. sum += i;
  19. }
  20. return sum;
  21. }
  22. }