-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminmax.java
More file actions
30 lines (27 loc) · 732 Bytes
/
minmax.java
File metadata and controls
30 lines (27 loc) · 732 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
import java.util.Scanner;
public class minmax {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
long[] arr = new long[5];
for(int i=0;i<=4;i++){
arr[i]=scan.nextInt();
}
miniMaxSum(arr);
}
public static void miniMaxSum(long[] arr){
long max=arr[0],min=arr[0],sum=0;
for(int i=1;i<arr.length;i++){
if(arr[i]<min){
min=arr[i];
}
if(arr[i]>max){
max=arr[i];
}
//for maximum score
}
for(int i=0;i<arr.length;i++){
sum=sum+arr[i];
}
System.out.println((sum-min)+" "+(sum-max));
}
}