-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConditionalOperators.java
More file actions
102 lines (82 loc) · 1.99 KB
/
ConditionalOperators.java
File metadata and controls
102 lines (82 loc) · 1.99 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package JavaSessions;
public class ConditionalOperators {
public static void main(String[] args) {
int a = 10;
int b = 20;
System.out.println(a == b);
if (a == b) {
System.out.println("both are equal");
} else {
System.out.println("both are not equal");
}
// dead code:
if (true) {
System.out.println("PASS");
} else {
System.out.println("FAIL");
}
boolean flag = true;
if (flag) {
System.out.println("ele is visible");
} else {
System.out.println("ele is not visible");
}
int total = 60;
if (total <= 100) {
System.out.println("total is less than or eq to 100");
if (total >= 80) {
System.out.println("total is gr than or eq to 80");
if (total == 80) {
System.out.println("GRADE A");
} else {
System.out.println("PASS");
}
} else {
System.out.println("NA");
}
} else {
System.out.println("BYE");
}
// logic -- to launch the browser - ch, ff, safari
// String browser = "safari";
// if(browser.equals("chrome")) {
// System.out.println("chrome launch");
// }
// if(browser.equals("firefox")) {
// System.out.println("ff launch");
// }
// if(browser.equals("safari")) {
// System.out.println("safari launch");
// }
// else {
// System.out.println("Plz pass the right browser name");
// }
String browser = "chrome";
if (browser.equals("chrome")) {
System.out.println("chrome launch");
}
else if(browser.equals("firefox")) {
System.out.println("ff launch");
}
else if(browser.equals("safari")) {
System.out.println("safari launch");
}
else {
System.out.println("Plz pass the right browser name");
}
//WAP - three diff numbers -- find out the highest number
int x = 500;
int y = 600;
int z = 800;
//&& - short circuit operator
if(x>y && x>z) {//false && false ==> false
System.out.println("x is the highest");
}
else if(y>z) {//true
System.out.println("y is the highest");
}
else {
System.out.println("z is the highest");
}
}
}