Jamez-s 6 anni fa
parent
commit
477824df5e
3 ha cambiato i file con 26 aggiunte e 1 eliminazioni
  1. BIN
      Main.class
  2. 6
    0
      Main.ctxt
  3. 20
    1
      Main.java

BIN
Main.class Vedi File


+ 6
- 0
Main.ctxt Vedi File

@@ -0,0 +1,6 @@
1
+#BlueJ class context
2
+comment0.target=Main
3
+comment0.text=\n\ Created\ by\ iyasuwatts\ on\ 10/17/17.\n
4
+comment1.params=args
5
+comment1.target=void\ main(java.lang.String[])
6
+numComments=2

+ 20
- 1
Main.java Vedi File

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