-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSumAvgMax.java
More file actions
36 lines (29 loc) · 814 Bytes
/
SumAvgMax.java
File metadata and controls
36 lines (29 loc) · 814 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
28
29
30
31
32
33
34
35
36
package array;
import java.util.Scanner;
public class MainClass {
static Scanner input = new Scanner(System.in);
public static void main(String[] args) {
System.out.print("How many Numbers you want to Store: ");
int limit,num,n,i,max=0,sum=0;
limit=input.nextInt();
int[] number = new int[limit];
System.out.print("How many numbers you want to take: ");
num=input.nextInt();
for(i=1;i<=num;i++) {
System.out.print("Enter Number "+i+": ");
number[i]=input.nextInt();
}
for(i=1;i<=num;i++) {
sum=sum+number[i];
}
System.out.println("Sum is :"+sum);
double avg=(sum/num);
System.out.println("Average is : "+avg);
for(i=1;i<=num;i++) {
if(number[i]>max) {
max=number[i];
}
}
System.out.println("Max = "+max);
}
}