-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquestion8.java
More file actions
33 lines (29 loc) · 1.01 KB
/
Copy pathquestion8.java
File metadata and controls
33 lines (29 loc) · 1.01 KB
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
package arrays;
import java.util.*;
public class question8 {
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
System.out.println("enter the input for the arrays-");
int size = sc.nextInt();
int numbers[] = new int[size];
//inputing
for(int i=0; i<size; i++) {
5System.out.println("the values in the arrays for"+ i +"position is");
numbers[i] = sc.nextInt();
}
//initialize min and max
int max = numbers[0];
int min = numbers[0];
//looping through
for(int i=0; i<numbers.length; i++){
if (numbers[i] > max){
max = numbers[i];//updating the array to the max values its find the array which we defined
}
if (numbers[i] < min){
min = numbers[i];//updating the min value
}
}
System.out.println("Maximum value: " + max);
System.out.println("Minimum value: " + min);
}
}