12345678910111213141516171819202122232425 |
- /**
- * Created by iyasuwatts on 10/17/17.
- */
- import java.util.Scanner;
-
- public class Main {
-
- public static void addIntegers()
- {
- Scanner input = new Scanner(System.in);
-
- int userInput;
- System.out.println("Please enter a positive integer: ");
- userInput = input.nextInt();
-
- int sumTotal = 0;
-
- for (int i = 1; i <= userInput; i++) {
- sumTotal += i;
- }
-
- System.out.println("The sum of the integers between 1 and " + userInput + " equals " + sumTotal + ".");
- }
- }
|