Decisions Examples
STOP LIGHT
Given a stoplight color String(“red”, “green”, “yellow”), and a status of traffic String(“clear” or “busy”) write code to print out the answer to Can I turn? Solution also shows how to turn multi-return if-then-clause into a single return using interim variable.
boolean makeTurn; String light; String status;
Leap Year
Given an input year of type int, write code to determine if that year is a leap year.
Leap years can be calcuated by the following formula: