-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode 51.txt
39 lines (24 loc) · 891 Bytes
/
code 51.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package usingarrays;
import javax.swing.JOptionPane;
public class UsingArrays{
public static void main(String[] args){
int[] intN = new int[10];
String[] strNames = new String[]{"Jack", "Jane", "Joe"};
System.out.println(strNames[0]);
System.out.println(strNames[1]);
System.out.println(strNames[2]);
// System.out.println(strNames[3]); //error Index out of bounds ??
int intCount;
int intSum;
double dblAverage;
intSum = 0;
for(intCount = 0; intCount <= 9; intCount++){
intN[intCount] = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter number " + intCount + ":"));
System.out.println(intN[intCount]);
intSum = intSum + intN[intCount];
}
System.out.println("The sum is " + intSum);
dblAverage = intSum / 10;
System.out.println("The average is " + dblAverage);
}
]