-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathminMaxThree.java
More file actions
30 lines (26 loc) · 772 Bytes
/
minMaxThree.java
File metadata and controls
30 lines (26 loc) · 772 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
import java.util.Scanner;
//Program to find min and max from three numbers
public class minMaxThree {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Enter first number: ");
int n1 = in.nextInt();
System.out.print("Enter second number: ");
int n2 = in.nextInt();
System.out.print("Enter third number: ");
int n3 = in.nextInt();
if (n1 > n2 & n1 > n3)
System.out.println("Max is " + n1);
else if (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);
else if (n2 < n1 & n2 < n3)
System.out.println("Min is " + n2);
else
System.out.println("Min is " + n3);
in.close();
}
}