Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
A swimming pool gives a teen ticket to anyone aged from to , both included. A programmer writes this.
INPUT Age
IF Age > 12 AND Age < 19
THEN
OUTPUT "Teen ticket"
ELSE
OUTPUT "Standard ticket"
ENDIFThe test plan uses the ages , , and . Which age shows that the algorithm is wrong? Correct the algorithm.
Normal data is accepted. Abnormal data should be rejected. Extreme data is the largest or smallest accepted value. Boundary data is the largest or smallest accepted value and the value next to it that is rejected. Find errors by dry-running with simple data and comparing with the expected result.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
Step 1. Each test.
16 > 12 AND 16 < 19 is true. Teen. Pass.13 > 12 is true and 13 < 19 is true. Teen. Pass.19 < 19 is false. Standard. Fail.Step 2. The correction. IF Age >= 13 AND Age <= 19, or IF Age > 12 AND Age < 20.
Answer: the age shows the error. It is boundary data (the largest accepted value), which is why boundary tests matter.
Check. After the correction, run all four tests again. They all pass.
Log in to join the discussion.
Loading…