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