-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDecisionLoopTest01.java
48 lines (42 loc) · 1.63 KB
/
DecisionLoopTest01.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
/**
* Example of boolean expressions
*
* @author Ken Fogel
*/
public class DecisionLoopTest01 {
/**
* This method is where the program begins doing useful work. You can name it anything
* you want but by convention it should be a verb.
*/
public void perform() {
// Comparison operators
int x = 4;
int y = 6;
System.out.println(x + " == " + y + ": " + (x == y));
System.out.println(x + " > " + y + ": " + (x > y));
System.out.println(x + " < " + y + ": " + (x < y));
System.out.println(x + " >= " + y + ": " + (x >= y));
System.out.println(x + " <= " + y + ": " + (x <= y));
// Logical Operators
int z = 5;
System.out.println("(" + z + " > " + x + " && " + z + " < " + y +"): " + (z > x && z < y));
z = 8;
System.out.println("(" + z + " < " + x + " || " + z + " > " + y +"): " + (z < x || z > y));
}
/**
* Where the program begins
*
* @param args Command line arguments, not used in this program
*/
public static void main(String[] args) {
var decisionLoopTest01 = new DecisionLoopTest01();
decisionLoopTest01.perform();
}
}
/***********************************************************************
* This work is licensed under the Creative Commons Attribution 4.0 *
* International License. To view a copy of this license, *
* visit http://creativecommons.org/licenses/by/4.0/ *
* or send a letter to *
* Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. *
***********************************************************************/