Browse Source

comleted SumOfInput

thulasi 6 years ago
parent
commit
4b130b7ddf
4 changed files with 47 additions and 13 deletions
  1. BIN
      Main.class
  2. 8
    0
      Main.ctxt
  3. 27
    1
      Main.java
  4. 12
    12
      package.bluej

BIN
Main.class View File


+ 8
- 0
Main.ctxt View File

@@ -0,0 +1,8 @@
1
+#BlueJ class context
2
+comment0.target=Main
3
+comment1.params=n
4
+comment1.target=Main(int)
5
+comment2.params=args
6
+comment2.target=void\ main(java.lang.String[])
7
+comment2.text=public\ static\ int\ getN(){\n\ \ \ \ \ \ \ \ return\ n;\n\ \ \ \ }\n\ \ \ \ \n\ \ \ \ public\ static\ void\ setN(int\ a){\n\ \ \ \ \ \ \ \ n\=a;\n}
8
+numComments=3

+ 27
- 1
Main.java View File

@@ -1,9 +1,35 @@
1
+
2
+
3
+
1 4
 /**
2 5
  * Created by iyasuwatts on 10/17/17.
3 6
  */
7
+import java.util.*;
4 8
 public class Main {
9
+    private static int num;
10
+    
11
+    public Main(int n){
12
+        
13
+    }
5 14
 
15
+    /*public static int getN(){
16
+        return n;
17
+    }
18
+    
19
+    public static void setN(int a){
20
+        n=a;
21
+    }   */
22
+    
6 23
     public static void main(String[] args){
7
-
24
+        
25
+        //setN(0);
26
+        Scanner input = new Scanner(System.in);
27
+        System.out.println("Please enter a number");
28
+        int num = input.nextInt(); 
29
+        int sum = 0;
30
+        for(int i = num; i>=1; i--){
31
+            sum += i;
32
+        }
33
+        System.out.println("sum of 1 to " + num + " is " + sum);
8 34
     }
9 35
 }

+ 12
- 12
package.bluej View File

@@ -1,18 +1,18 @@
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=403
5
+editor.fx.0.y=29
6 6
 objectbench.height=164
7
-objectbench.width=776
7
+objectbench.width=1256
8 8
 package.divider.horizontal=0.6
9
-package.divider.vertical=0.6845018450184502
10
-package.editor.height=364
11
-package.editor.width=674
12
-package.editor.x=-816
13
-package.editor.y=445
14
-package.frame.height=600
15
-package.frame.width=800
9
+package.divider.vertical=0.7432432432432432
10
+package.editor.height=488
11
+package.editor.width=1154
12
+package.editor.x=0
13
+package.editor.y=23
14
+package.frame.height=724
15
+package.frame.width=1280
16 16
 package.numDependencies=0
17 17
 package.numTargets=1
18 18
 package.showExtends=true