Bladeren bron

finds the consecutive sum of inputs

Jevit Tith 6 jaren geleden
bovenliggende
commit
a32a0ccd23
2 gewijzigde bestanden met toevoegingen van 20 en 6 verwijderingen
  1. 14
    0
      Main.java
  2. 6
    6
      package.bluej

+ 14
- 0
Main.java Bestand weergeven

@@ -1,9 +1,23 @@
1 1
 /**
2 2
  * Created by iyasuwatts on 10/17/17.
3 3
  */
4
+import java.util.*;
4 5
 public class Main {
5 6
 
6 7
     public static void main(String[] args){
8
+        System.out.println("Choose a positive whole number");
9
+        Scanner userInput = new Scanner(System.in);
10
+        String userNumber = userInput.nextLine();
11
+        Integer userNumberConverted = Integer.parseInt(userNumber);
12
+        Integer sumTotal = 0; 
13
+        
14
+        for (int i = userNumberConverted; i > 0; i--) {
15
+            sumTotal = userNumberConverted + i;
16
+        }
17
+        
18
+        System.out.println("The total sum is " + sumTotal);
7 19
 
8 20
     }
21
+    
22
+    
9 23
 }

+ 6
- 6
package.bluej Bestand weergeven

@@ -1,16 +1,16 @@
1 1
 #BlueJ package file
2
-editor.fx.0.height=0
3
-editor.fx.0.width=0
4
-editor.fx.0.x=0
5
-editor.fx.0.y=0
2
+editor.fx.0.height=722
3
+editor.fx.0.width=800
4
+editor.fx.0.x=397
5
+editor.fx.0.y=-907
6 6
 objectbench.height=164
7 7
 objectbench.width=776
8 8
 package.divider.horizontal=0.6
9 9
 package.divider.vertical=0.6845018450184502
10 10
 package.editor.height=364
11 11
 package.editor.width=674
12
-package.editor.x=-816
13
-package.editor.y=445
12
+package.editor.x=-161
13
+package.editor.y=-817
14 14
 package.frame.height=600
15 15
 package.frame.width=800
16 16
 package.numDependencies=0