| If Statement Worksheet #2 | Name - |
| Day of Week - |
Use good style when writing if statements. Use curly braces around all if and else clauses to avoid making dangling else errors.
1. Write an if statement that displays the message "within range " if the value of the integer variable number is greater than or equal to 5 but less than 10. Otherwise, the message "not finished" displays.
2. Write an if statement that displays "excellent" if the integer variable grade is
greater than or equal to 90. The word "average" should be displayed if grade is greater than or equal to 70 but less than 90. The word "poor" should display
if grade is less than 70.
3. Write an if statement that compute's and displays "no admittance" if the integer variable age is less than 21 or greater than 65. If age is greater than or equal to 21 and less than or equal to
65, the phrase "option 1" should display if age is an even number and "option 2" should display if age is an odd number.