Which decision construct should you use to evaluate a single expression to either true or false?
2.
Evaluating expressions to true or false for both types of decision constructs is accomplished using ________ logic.
3.
If you want code to execute when the expression of an if statement evaluates to false, include an ____ clause.
4.
Which decision construct should you use when evaluating the result of an expression that may equate to one of many possible values?
5.
Is it possible that more than one case statement may have its code execute?
Answers
1.
The if construct
2.
Boolean
3.
else
4.
switch
5.
No, never.
Exercises
1.
Create a project that enables the user to enter text into a text box. Use an if construct to determine whether the text entered is a Circle, Triangle, Square, or Pentagon, and display the number of sides the entered shape has. If the text doesn't match one of these shapes, let the users know that they must enter a shape.
2.
Rewrite the the project you created in Exercise 1 so that it uses a switch construct instead of an if construct.