- Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathWhileLoopDemo2.java
More file actions
Latest commit
24 lines (23 loc) · 494 Bytes
/
Copy pathWhileLoopDemo2.java
File metadata and controls
24 lines (23 loc) · 494 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
importjava.util.Scanner;
classWhileLoopDemo2{
publicstaticvoidmain(String[] args){
Scannersc = newScanner(System.in);
System.out.println("Enter a number : ");
inta = sc.nextInt();
intmax=0,min=0;
//min = Integer.MAX_VALUE;
//max = Integer.MIN_VALUE;
while(a!=0){
a = sc.nextInt();
if(a>max){
max = a;
}
if(a<min){
min = a;
}
}
System.out.println("min : "+min);
System.out.println("max : "+max);
System.out.println("loop finished");
}
}