12345678910111213141516171819202122232425
  1. /**
  2. * Created by iyasuwatts on 10/17/17.
  3. */
  4. import java.util.Scanner;
  5. public class Main {
  6. public static void addIntegers()
  7. {
  8. Scanner input = new Scanner(System.in);
  9. int userInput;
  10. System.out.println("Please enter a positive integer: ");
  11. userInput = input.nextInt();
  12. int sumTotal = 0;
  13. for (int i = 1; i <= userInput; i++) {
  14. sumTotal += i;
  15. }
  16. System.out.println("The sum of the integers between 1 and " + userInput + " equals " + sumTotal + ".");
  17. }
  18. }