Great work! Control flow allows Java programs to execute code blocks depending on Boolean expressions. What did we learn about control flow so far?
!are used to build Boolean expressions and have a defined order of operations
elsestatements are used to conditionally execute blocks of code
Ternary Conditional: a shortened version of an
elsestatement that returns a value based on the value of a Boolean expression
Switch: allows us to check equality of a variable or expression with a value that does not need to be a Boolean
Use the precedence rules to help you evaluate the Boolean expression in the single line comment above the
Then, set the
tricky equal to the result (either
Change the Boolean expression in the
if statement so that your program will print out the code in the
else block instead.
Set the value of the
subwayTrain equal to the
case that will print
"This is a Brooklyn bound train!" to the console.