Guided Notes
Control Flow
Booleans, if/else, the ternary operator, switch, while, do/while, for, for-each, break, and continue.
if, else if, else
Slide 1 / 5if (score >= 90) { grade = 'A'; } else if (score >= 80) { grade = 'B'; } else { grade = 'F'; }
Conditions must be boolean expressions; only the first true branch runs, so test the highest thresholds first. Always use braces, even for one line β it prevents bugs when someone adds a second line later.
The ternary operator is a short if/else that produces a value: String label = age >= 18 ? "adult" : "minor";
