The parentheses of an if hold a boolean — any comparison (> < == !=) or a combination joined with && / ||, just like Module 1's logic.
if
boolean
> < == !=
&&
||
if (score >= 60) { ... } // a comparison if (n >= 1 && n <= 10) { ... } // combined with &&
▶ Try it: run this, then change n — the condition n % 2 == 0 decides even vs odd.
n
n % 2 == 0
Which condition is true exactly when n is even?
Which condition is true when x is between 1 and 10 inclusive?
x
Match each condition to when it is true.
Fill the blank so the condition is true exactly when n is negative.
True or false?
Type exactly what this program prints.
public class Main { public static void main(String[] a){ int n = 12; if (n % 2 == 0 && n > 10) { System.out.println("big even"); } else { System.out.println("other"); } }}