At the end of this lesson, you will be able to:
understand and use select case statements
With a pencil and paper, answer the following questions:
Write 1 example in pseudocode of using an IF..ELSE IF..ELSE statement in daily life.
Write the following expressions with symbols and variables:
a) a negative number
b) a number that is 18 or greater
c) a number different from 0
Draw the flowchart for a program that does the following:
Generate a random number between 1 and 3.
If the number is 3, display "The light is red"
Otherwise, if the number is 2, display "The light is yellow"
Otherwise, display, "The light is green."
Write 3 test cases for the above program: 1 test case for a light that is red, 1 for a light that is green and 1 for a light that is yellow.
if..then..elseif..else statements
from the online book Computer Based Problem Solving by Patrick Coxall, read:
in Python it is called "Match Case"
in C++ it is called "Switch Case"
Note: A, B, C... in the flowchart below represent the possible values of "grade level"
create a "Month" program that asks the user to enter a number between 1 and 12
the program will then display the month that represents the number
for example, if the user enters 1, the program will print "<The number> is January."
if a number outside of the range 1..12 is entered, display "<The number> does not represent a month."
in groups of 2, do the following on the board for today's daily assignment:
Top-Down Design
Flow Chart
Pseudocode
Test Cases
complete the Daily Assignment section in Hãpara Workspace for this day
if Hãpara is not working, make a copy of this document
move it to your IMH-ICS folder for this course
recreate the same program in C++
in C++ you will use a "Switch" statement