What validation cannot do

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

What validation cannot do

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. A user should type 51 for their age but types 15. A range check allows 0 to 120. What happens?
A 15 is rejected as invalid
B 15 is accepted, but it is wrong
2. Which statement about validation is correct?
A It checks data is reasonable and in the right form
B It proves the data is correct
3. A student's real date of birth is 04/09/2010. They type 14/09/2010. A format check expects DD/MM/YYYY. What is the result?
A It passes the format check but is wrong
B The format check finds the wrong day
4. Which is true of a valid value?
A It can still be wrong
B It is always correct
5. Which check is also needed to help catch a typing mistake such as 15 instead of 51?
A A second range check
B Verification, such as a double entry check

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1Age: 15 typed instead of 51 (range check 0-120 passes) AIF Age >= 0 AND Age <= 120 THEN OUTPUT "Accepted" ENDIF
2DOB: 12/04/2008 typed instead of 12/04/2006 (format check passes) BIF Age1 <> Age2 THEN OUTPUT "Please re-enter" ENDIF
3Validation checks that data is reasonable and in the right form, not that it is correct CThe date is in the correct format, so validation accepts it, but it is not the person's real date of birth.
4Verification is also needed to catch valid but wrong data, for example by entering the data twice and comparing DValidation only rejects unreasonable data. Typing mistakes that give a reasonable value, such as 15 for 51, get through, so verification is also needed.
5A range check on age passed, so the age must be correct. EThe value is valid because it is in the allowed range, but it is still wrong. Validation cannot tell it is the wrong number.
6Validation is enough because it stops all typing mistakes. FPassing validation does not prove the data is correct. 15 and 51 both pass a range check of 0 to 120, so a wrong age can still be accepted.

Definitions

valid but wrong

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
Age ← 15 // meant to type 51 Valid ← Age >= 0 ___ Age <= 120 OUTPUT Valid // TRUE but still wrong
2.
DOB ← "05/11/2008" // typed wrong date Valid ← ______(DOB) = 10 // length check OUTPUT Valid // TRUE even if date is wrong
3.
DECLARE Age : _______ Age ← 15 // type check passes OUTPUT Age // but 51 was meant
4.
OUTPUT "You entered ", Age OUTPUT "Is this correct? Y/N" _____ Confirm
5.
INPUT Age INPUT AgeAgain Matches ← Age _ AgeAgain // double entry

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A INPUT Age
B IF Age >= 0 AND Age <= 120
C THEN OUTPUT "Accepted"
D ENDWHILE
E OUTPUT "Check 15 or 51?"
Question 2
A INPUT Age
B IF Age >= 0 AND Age <= 120
C THEN
D OUTPUT "Age is correct"
E ENDIF
Question 3
A # Format check on DOB
B INPUT DOB
C IF LENGTH(DOB) = 10
D THEN OUTPUT "Format OK"
E ENDIF
Question 4
A INPUT Age1
B INPUT Age2
C IF Age1 <> Age2
D THEN OUTPUT "Entries match"
E ELSE OUTPUT "Re-enter"
F ENDIF
Question 5
A OUTPUT "Enter your age"
B INPUT Age
C WHILE Age < 0 AND Age > 120 DO
D INPUT Age
E ENDWHILE

Answer Key

What validation cannot do
Section A: Quick Questions
Q1
B — 15 is accepted, but it is wrong
Q2
A — It checks data is reasonable and in the right form
Q3
A — It passes the format check but is wrong
Q4
A — It can still be wrong
Q5
B — Verification, such as a double entry check
Section B: Match the Pairs
Q1
Age: 15 typed instead of 51 (range check 0-120 passes) → The value is valid because it is in the allowed range, but it is still wrong. Validation cannot tell it is the wrong number.
Q2
DOB: 12/04/2008 typed instead of 12/04/2006 (format check passes) → The date is in the correct format, so validation accepts it, but it is not the person's real date of birth.
Q3
Validation checks that data is reasonable and in the right form, not that it is correct → IF Age >= 0 AND Age <= 120 THEN OUTPUT "Accepted" ENDIF
Q4
Verification is also needed to catch valid but wrong data, for example by entering the data twice and comparing → IF Age1 <> Age2 THEN OUTPUT "Please re-enter" ENDIF
Q5
A range check on age passed, so the age must be correct. → Passing validation does not prove the data is correct. 15 and 51 both pass a range check of 0 to 120, so a wrong age can still be accepted.
Q6
Validation is enough because it stops all typing mistakes. → Validation only rejects unreasonable data. Typing mistakes that give a reasonable value, such as 15 for 51, get through, so verification is also needed.
Section C: Definitions
Q1
valid but wrong — Validation only checks data is reasonable and in the right form, so a valid value can still be wrong, e.g. age 15 typed instead of 51. Verification is also needed.
Section D: Fill in the Blanks
Q1
Age ← 15 // meant to type 51 Valid ← Age >= 0 AND Age <= 120 OUTPUT Valid // TRUE but still wrong
Q2
DOB ← "05/11/2008" // typed wrong date Valid ← LENGTH(DOB) = 10 // length check OUTPUT Valid // TRUE even if date is wrong
Q3
DECLARE Age : INTEGER Age ← 15 // type check passes OUTPUT Age // but 51 was meant
Q4
OUTPUT "You entered ", Age OUTPUT "Is this correct? Y/N" INPUT Confirm
Q5
INPUT Age INPUT AgeAgain Matches ← Age = AgeAgain // double entry
Section E: Spot the Error
Q1
D — An IF statement must be closed with ENDIF, not ENDWHILE. ENDWHILE belongs to a WHILE loop. Note that the range check accepts both 15 and 51, so a typing slip still passes.
Q2
D — Validation only shows that a value is reasonable, not that it is correct. 15 typed instead of 51 would pass this check, so the message should say the age is reasonable.
Q3
A — Cambridge pseudocode comments start with //, not #. The comment should be // Format check on DOB. The check only tests the format, so a wrong date can still pass.
Q4
C — A double entry check accepts the data when both entries are equal. Using <> would say 'Entries match' when they differ. It should be IF Age1 = Age2. This is verification, which catches errors that validation misses.
Q5
C — No number is both below 0 and above 120, so AND makes the condition always false. It must be OR so that invalid ages are rejected. Even so, a valid but wrong age such as 15 for 51 still gets through.