-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMinMax.java
More file actions
47 lines (32 loc) · 839 Bytes
/
MinMax.java
File metadata and controls
47 lines (32 loc) · 839 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
37
38
39
40
41
42
43
44
45
46
47
import java.util.Scanner;
public class MinMax {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner s = new Scanner(System.in);
System.out.println("Enter number of numbers ");
int n = s.nextInt();
int i = 1; // next number to be taken
int min = Integer.MAX_VALUE;
int max = Integer.MIN_VALUE;
while( i <= n){
System.out.println("Enter " + i +" number :");
int currentNum = s.nextInt();
if(currentNum < min){
min = currentNum;
}
if(currentNum > max){
max = currentNum;
}
//i = i + 1;
++i;
}
System.out.println("Min is :"+ min);
System.out.println("Max is :"+max);
// int a = 10, b = 11;
//
// if( a++ < 10 || b++ > 10){
// System.out.println("Inside if");
// }
// System.out.println("a : "+ a+" b : "+ b);
}
}