- Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathminMaxThree.java
30 lines (26 loc) · 772 Bytes
/
minMaxThree.java
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
importjava.util.Scanner;
//Program to find min and max from three numbers
publicclassminMaxThree {
publicstaticvoidmain(String[] args) {
Scannerin = newScanner(System.in);
System.out.print("Enter first number: ");
intn1 = in.nextInt();
System.out.print("Enter second number: ");
intn2 = in.nextInt();
System.out.print("Enter third number: ");
intn3 = in.nextInt();
if (n1 > n2 & n1 > n3)
System.out.println("Max is " + n1);
elseif (n2 > n1 & n2 > n3)
System.out.println("Max is " + n2);
else
System.out.println("Max is " + n3);
if (n1 < n2 & n1 < n3)
System.out.println("Min is " + n1);
elseif (n2 < n1 & n2 < n3)
System.out.println("Min is " + n2);
else
System.out.println("Min is " + n3);
in.close();
}
}