-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConditionalStatements.java
More file actions
45 lines (45 loc) · 1.4 KB
/
Copy pathConditionalStatements.java
File metadata and controls
45 lines (45 loc) · 1.4 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
36
37
38
39
40
41
42
43
44
45
import java.util.Scanner;
class ConditionalStatements {
public static void main(String[] args) {
int num1, num2,num3;
Scanner sc = new Scanner(System.in);
num1 = sc.nextInt();
num2 = sc.nextInt();
num3 = sc.nextInt();
// only if statements
if(num1 > num2 && num1 > num3){
System.out.println("num1 is the greater number");
}
if(num2 > num1 && num2 > num3){
System.out.println("num2 is the greater number");
}
System.out.println("num3 is the greater number");
// if-else statements
if(num1 > num2 && num1 > num3){
System.out.println("num1 is the greater number");
}
else if(num2 > num1 && num2 > num3){
System.out.println("num2 is the greater number");
}
else{
System.out.println("num3 is the greater number");
}
// nested if statements
if(num1 > num2){
if(num1 > num3){
System.out.println("num1 is the greater number");
}
else{
System.out.println("num3 is the greater number");
}
}
else{
if(num2 > num3){
System.out.println("num2 is the greater number");
}
else{
System.out.println("num3 is the greater number");
}
}
}
}