public class SimpleBooleanExpressions
2: /**
3: * A program to demonstrate how to use simple boolean expressions.
4: *
5: * @author Mark Young (A00000000)
6: */
7: public class SimpleBooleanExpressions {
9: public static void main(String[] args) {
10: // create variables
11: int grade, age, guess, secretNumber;
12: double x, y, z;
14: // initialize them
15: grade = 50;
16: age = 18;
17: guess = 50;
18: secretNumber = 42;
19: x = 4.0;
20: y = 7.3;
21: z = 9.9;
23: // if grade is greater than or equal to 50...
24: System.out.println("Your grade is " + grade);
25: if (grade >= 50) {
26: // print out “You passed!â€
27: System.out.println("You passed!");
28: }
30: // if age is less than 18...
31: System.out.println("Your age is " + age);
32: if (age < 18) {
33: // print "I'm sorry, but you're not allowed to see this movie."
34: System.out.println("I'm sorry, "
35: + "but you're not allowed to see this movie.");
36: }
38: // if guess is equal to secretNumber...
39: System.out.println("Your guess is " + guess);
40: if (guess == secretNumber) {
41: // print "You guessed it!"
42: System.out.println("You guessed it!");
43: }
45: // if y plus 9 is less than or equal to x times 2...
46: System.out.println("if " + y + " plus 9 is less than or equal to "
47: + x + " times 2, then z should be set to zero.");
48: if (y + 9 <= x * 2) {
49: // set z equal to zero.
50: z = 0;
51: }
52: System.out.println("z is " + z);
53: }
55: }