We could write a bunch of if statements when testing one variable but there is a cleaner way of doing it
Switch Statement
in the parenthesis is the expression you would like to evaluate: “grade”
each case is a possible value
break tells the switch statement to terminate
default is optional and runs when the grade is not found (similar to else)
10 of 12
Not operator
Negates any boolean expression
If the boolean expression was true, with the not operator it becomes false
if the the boolean expression was false, it now becomes true
The not operator must precede the boolean expression it will negate
11 of 12
Operator precedence
The book talks about operator precedence on page 283
I like to view it a simpler way, if you’re not sure of which operator will have precedence, use parentheses and you can explicitly state which one should come first