-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMinMaxFinder.java
More file actions
35 lines (29 loc) · 1.22 KB
/
Copy pathMinMaxFinder.java
File metadata and controls
35 lines (29 loc) · 1.22 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
34
35
import java.util.Scanner;
public class MinMaxFinder {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// Reading three integers from the user
System.out.println("Enter the first integer:");
int num1 = scanner.nextInt();
System.out.println("Enter the second integer:");
int num2 = scanner.nextInt();
System.out.println("Enter the third integer:");
int num3 = scanner.nextInt();
// Finding the smallest number
if (num1 <= num2 && num1 <= num3) {
System.out.println("The smallest number is: " + num1);
} else if (num2 <= num1 && num2 <= num3) {
System.out.println("The smallest number is: " + num2);
} else {
System.out.println("The smallest number is: " + num3);
}
// Finding the largest number
if (num1 >= num2 && num1 >= num3) {
System.out.println("The largest number is: " + num1);
} else if (num2 >= num1 && num2 >= num3) {
System.out.println("The largest number is: " + num2);
} else {
System.out.println("The largest number is: " + num3);
}
}
}