Преглед изворни кода

Made program give sum of number input by user.

Jennifer Tinkler пре 6 година
родитељ
комит
7b17891ece
8 измењених фајлова са 98 додато и 13 уклоњено
  1. BIN
      Main.class
  2. 5
    0
      Main.ctxt
  3. 19
    2
      Main.java
  4. BIN
      MainTest.class
  5. 13
    0
      MainTest.ctxt
  6. 42
    0
      MainTest.java
  7. 0
    0
      README.TXT
  8. 19
    11
      package.bluej

+ 5
- 0
Main.ctxt Прегледај датотеку

@@ -0,0 +1,5 @@
1
+#BlueJ class context
2
+comment0.target=Main
3
+comment1.params=args
4
+comment1.target=void\ main(java.lang.String[])
5
+numComments=2

+ 19
- 2
Main.java Прегледај датотеку

@@ -1,9 +1,26 @@
1 1
 /**
2
- * Created by iyasuwatts on 10/17/17.
3
- */
2
+ * Create
3
+ d by iyasuwatts on 10/17/17.
4
+ */import java.util.Scanner;
4 5
 public class Main {
5 6
 
6 7
     public static void main(String[] args){
8
+        
9
+        /*ask user for a number*/
10
+        System.out.println("Enter a number");
11
+        Scanner scan = new Scanner(System.in);
12
+        
13
+        int n = scan.nextInt();
14
+        
15
+        /*declare sum*/
16
+        int sum = 0;
17
+        
18
+        for (int i = 0; i <= n; i++)
19
+        
20
+        {
21
+            sum=sum+i;
22
+        }
23
+        System.out.println("Sum is " + sum);
7 24
 
8 25
     }
9 26
 }


+ 13
- 0
MainTest.ctxt Прегледај датотеку

@@ -0,0 +1,13 @@
1
+#BlueJ class context
2
+comment0.target=MainTest
3
+comment0.text=\n\ The\ test\ class\ MainTest.\n\n\ @author\ \ (your\ name)\n\ @version\ (a\ version\ number\ or\ a\ date)\n
4
+comment1.params=
5
+comment1.target=MainTest()
6
+comment1.text=\n\ Default\ constructor\ for\ test\ class\ MainTest\n
7
+comment2.params=
8
+comment2.target=void\ setUp()
9
+comment2.text=\n\ Sets\ up\ the\ test\ fixture.\n\n\ Called\ before\ every\ test\ case\ method.\n
10
+comment3.params=
11
+comment3.target=void\ tearDown()
12
+comment3.text=\n\ Tears\ down\ the\ test\ fixture.\n\n\ Called\ after\ every\ test\ case\ method.\n
13
+numComments=4

+ 42
- 0
MainTest.java Прегледај датотеку

@@ -0,0 +1,42 @@
1
+
2
+
3
+import static org.junit.Assert.*;
4
+import org.junit.After;
5
+import org.junit.Before;
6
+import org.junit.Test;
7
+
8
+/**
9
+ * The test class MainTest.
10
+ *
11
+ * @author  (your name)
12
+ * @version (a version number or a date)
13
+ */
14
+public class MainTest
15
+{
16
+    /**
17
+     * Default constructor for test class MainTest
18
+     */
19
+    public MainTest()
20
+    {
21
+    }
22
+
23
+    /**
24
+     * Sets up the test fixture.
25
+     *
26
+     * Called before every test case method.
27
+     */
28
+    @Before
29
+    public void setUp()
30
+    {
31
+    }
32
+
33
+    /**
34
+     * Tears down the test fixture.
35
+     *
36
+     * Called after every test case method.
37
+     */
38
+    @After
39
+    public void tearDown()
40
+    {
41
+    }
42
+}


+ 19
- 11
package.bluej Прегледај датотеку

@@ -1,20 +1,20 @@
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=632
5
+editor.fx.0.y=-1000
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=-261
13
+package.editor.y=-1006
14 14
 package.frame.height=600
15 15
 package.frame.width=800
16 16
 package.numDependencies=0
17
-package.numTargets=1
17
+package.numTargets=2
18 18
 package.showExtends=true
19 19
 package.showUses=true
20 20
 project.charset=UTF-8
@@ -24,9 +24,17 @@ readme.width=47
24 24
 readme.x=10
25 25
 readme.y=10
26 26
 target1.height=50
27
-target1.name=Main
27
+target1.name=MainTest
28 28
 target1.showInterface=false
29
-target1.type=ClassTarget
29
+target1.type=UnitTestTargetJunit4
30 30
 target1.width=80
31
-target1.x=70
32
-target1.y=10
31
+target1.x=100
32
+target1.y=-20
33
+target2.association=MainTest
34
+target2.height=50
35
+target2.name=Main
36
+target2.showInterface=false
37
+target2.type=ClassTarget
38
+target2.width=80
39
+target2.x=70
40
+target2.y=10