-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDecisionMaking.java
54 lines (47 loc) · 1.37 KB
/
DecisionMaking.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
50
51
52
53
54
public class DecisionMaking {
public static void main(String[] args) {
int a = 10;
int b = 20;
if (a < b) {
System.out.println("a is less than b");
} else {
System.out.println("a is greater than or equal to b");
}
// if-else-if ladder
int c = 30;
if (c == 10) {
System.out.println("Value of c is 10");
} else if (c == 20) {
System.out.println("Value of c is 20");
} else if (c == 30) {
System.out.println("Value of c is 30");
} else {
System.out.println("Value of c is not matching");
}
// nested if
int d = 10;
if (a == 10) {
if (b == 20) {
System.out.println("Value of a is 10 and b is 20");
}
}
// switch statement
char grade = 'C';
switch (grade) {
case 'A':
System.out.println("Excellent!");
break;
case 'B':
case 'C':
System.out.println("Well done");
break;
case 'D':
System.out.println("You passed");
case 'F':
System.out.println("Better try again");
break;
default:
System.out.println("Invalid grade");
}
}
}