Simple if Statement Example A program that asks the user for a temperature and displays a different message if the temperature is above or below 20 degrees.
Traffic Light Program (nested ifs) A program that displays the recommended actions depending on the color of a traffic light. This program uses nested if statements.
Traffic Light Program (switch) A program that displays the recommended actions depending on the color of a traffic light. Unlike the previous program, this implementation uses the switch statement.
Even vs. Odd Program A program that determines if an integer number is odd or even.
Heart Rate Program A program that asks the user for the number of hearbeats in 10 seconds, calculates the heartbeats per minute and makes a health recommendation.
Switching Values Program A program that askes the user for two numbers in variables x and y and switches them if the number in x is larger than the number in y.
Water Bill Program This program figures a water bill based on the demand charge
($35) and a $1.10 per 1000 gallons use charge. A $2 surcharge is added to accounts with an unpaid balance.