SAC EXAMPLE
2
Sequential Selection
Constructs
(
NOTE:
This does not implement the OOSD paradigm; see the last extension.)
The following SAC illustrates a simple of if-then-else
and if-then selection constructs in sequence. (a) If "Jan", "O",
and 70 are input, what will the output of this algorithm be? (b)
What does this algorithm do?
EXTENSIONS:
-
What set of test data would be necessary to completely
check the logic of this algorithm?
-
How could the first selection be accomplished using a simple
if-then construct?
-
In order to print out whether or not N$ is married,
what additions are needed in the SAC?
-
In order to classify a person as a child (age <
13), a teenager (13 = age < 20) or an adult (age >= 20),
what modifications to the SAC are necessary? (Hint: this is easier,
if nested selection constructs are used, so it can best be answered after
studying SAC EXAMPLE 3; however, try to answer this with sequential selections
only. Check your logic. Note the cumbersome logic that results.)
-

How
would the algorithms in this example be modified to represent OOSD?
(b) Would the different versions of this algorithm have different OOSD
versions?
SAQ:
Why isn't an if-then-else used as the second selection construct?