forked from MLSA-MUET-SZAB-Club-Khairpur-Mir-s/Learn-to-Code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLargestandSmallest.java
More file actions
24 lines (23 loc) · 831 Bytes
/
LargestandSmallest.java
File metadata and controls
24 lines (23 loc) · 831 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
import java.util.Scanner;
public class LargestandSmallest {
public static void main(String[] args) {
int largest = Integer.MIN_VALUE;
int smallest = Integer.MAX_VALUE;
Scanner sc = new Scanner(System.in);
int terminated;
do{
System.out.println("Enter the number ");
int x = sc.nextInt();
if(x<smallest) {
smallest=x;
}
if(x>largest){
largest=x;
}
System.out.println("If you want to continue this process then press 1 otherwise press 0");
terminated = sc.nextInt();
}while(terminated!=0);
System.out.println("The Smallest value is: " + smallest);
System.out.println("The Largest value is: " + largest);
}
}