-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayMinMax.java
More file actions
28 lines (25 loc) · 857 Bytes
/
ArrayMinMax.java
File metadata and controls
28 lines (25 loc) · 857 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
import java.io.*;
public class ArrayMinMax {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("ENTER THE NUMBER OF ELEMENTS");
int n = Integer.parseInt(br.readLine());
int arr[] = new int[n];
System.out.println("ENTER THE INTEGERS");
for (int i = 0; i < n; i++) {
arr[i] = Integer.parseInt(br.readLine());
}
int max = arr[0];
int min = arr[0];
for (int j = 1; j < n; j++) {
if (arr[j] > max) {
max = arr[j];
}
if (arr[j] < min) {
min = arr[j];
}
}
System.out.println("MAXIMUM NUMBER = " + max);
System.out.println("MINIMUM NUMBER = " + min);
}
}