-
Notifications
You must be signed in to change notification settings - Fork 32
/
GreatestOfFour.java
49 lines (48 loc) · 1.53 KB
/
GreatestOfFour.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import java.util.Scanner;
public class GreatestOfFour {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Please enter first number: ");
int number1 = sc.nextInt();
System.out.println("Please enter second number: ");
int number2 = sc.nextInt();
System.out.println("Please enter third number: ");
int number3 = sc.nextInt();
System.out.println("Please enter fourth number: ");
int number4 = sc.nextInt();
if(number1 > number2)
{
if(number1 > number3)
{
if(number1 > number4)
{
System.out.println("Largest of four numbers is: " + number1);
}
else
{
System.out.println("Largest of four numbers is: " + number4);
}
}
}
else if(number2 > number3)
{
if(number2 > number4)
{
System.out.println("Largest of four numbers is: " + number2);
}
else
{
System.out.println("Largest of four numbers is: " + number4);
}
}
else if(number3 > number4)
{
System.out.println("Largest of four numbers is: " + number3);
}
else
{
System.out.println("Largest of four numbers is: " + number4);
}
sc.close();
}
}