-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
27 lines (23 loc) · 756 Bytes
/
Main.java
File metadata and controls
27 lines (23 loc) · 756 Bytes
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
import java.util.*;
import java.lang.*;
public class Main {
public static void main(String[] args) {
Scanner t = new Scanner(System.in);
System.out.println("How many elements");
int num = t.nextInt();
int sum = 0;
float avg = 0;
int[] arr = new int[num];
System.out.println("Enter element");
for (int i = 0; i < arr.length; i++) {
arr[i] = t.nextInt();
}
System.out.println("array is here");
for (int i = 0; i < arr.length; i++) {
System.out.print(arr[i] + "\t");
sum = sum + arr[i];
avg = (float) sum / num;
}
System.out.println("sum is=" + sum + "\t" + avg);
}
}