Programming Fundamentals/Conditions/Nested Conditions
Nested conditions perform a sequence of different computations or actions depending on whether programmer-specified Boolean conditions evaluate to true or false.[1] This activity introduces nested conditions. This activity will help you understand how to use nested conditions in a program.
Objectives
edit- Understand nested condition concepts.
- Understand how nested conditions are specified in a program.
- Single-step through a program to observe nested condition execution.
Prerequisites
editLearners should already be familiar with conditions.
Introduction
editReview the flowchart example on the right.
Questions
edit- What flowcharting symbol is used to indicate a condition?
- How are nested conditions structured?
Activity
editWith a partner, perform the following:
- Using a visual programming language, create a program matching the flowchart on the right.
- Save the program.
- Test the program to verify that it works correctly.
- Trade places, so that both partners have an opportunity to "drive" the visual programming environment.
- Change the environment to use a slow run speed and/or step through the program one shape at a time.
- Working together, identify the nested conditions that would be used to either convert Fahrenheit temperature to Celsius or convert Celsius temperature to Fahrenheit, depending on user choice.
Applications
edit- Identify specific steps which must be followed when creating a program using nested conditions.
- Discuss your activity experience with your classmates. What surprised you? What have you learned that you can apply to your own school or work environment?