-
Notifications
You must be signed in to change notification settings - Fork 0
/
SortIntegers
43 lines (35 loc) · 1.43 KB
/
SortIntegers
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
36
37
38
39
40
41
42
43
import java.util.Scanner;
public class SortIntegers {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int num1, num2, num3;
System.out.println("Enter the three integers.");
num1 = input.nextInt();
num2 = input.nextInt();
num3 = input.nextInt();
if(num1 < num2 & num1 < num3 & num2 < num3)
{
System.out.printf("The numbers in order from smallest to largest are: %d, %d, %d", num1, num2, num3);
}
else if(num1 > num2 & num1 > num3 & num2 > num3)
{
System.out.printf("The numbers in order from smallest to largest are: %d, %d, %d", num3, num2, num1);
}
else if(num1 < num2 & num1 < num3 & num2 > num3)
{
System.out.printf("The numbers in order from smallest to largest are: %d, %d, %d", num1, num3, num2);
}
else if(num2 > num1 & num2 > num3 & num1 > num3)
{
System.out.printf("The numbers in order from smallest to largest are: %d, %d, %d", num3, num1, num2);
}
else if (num3 > num1 & num3 > num2 & num1 > num2)
{
System.out.printf("The numbers in order from smallest to largest are: %d, %d, %d", num2, num1, num3);
}
else if (num2 < num3 & num2 < num1 & num3 < num1)
{
System.out.printf("The numbers in order from smallest to largest are: %d, %d, %d", num2, num3, num1);
}
} //end of class
} //end of main