7.5

7.5 Validation and Verification

Understanding the need for validation and verification checks, and the different types of each method used to ensure data entered into a computer system is correct and reasonable.

Learning Objectives

By the end of this lesson, you will be able to:

  • Understandthe need for validation checks to be made on input data
  • Describethe six types of validation check: range, length, type, presence, format and check digit
  • WriteCIE pseudocode and Python code to perform each type of validation check
  • Understandthe need for verification checks to be made on input data
  • Describethe different types of verification check: double entry, visual/screen check, parity check and checksum
  • Explainthe difference between validation and verification
  • Applyvalidation and verification techniques to real-world scenarios

Key Terms

Validation

An automated process where a computer checks if a user input is sensible and meets the program's requirements before it is processed.

Verification

The act of checking that data is accurate when entered into a system — that data does not change, either accidentally or on purpose, as it is entered.

Range check

Ensures that the data entered as a number falls within a particular range (e.g. a percentage between 0 and 100 inclusive).

Length check

Checks the length of a string — ensures the input includes the correct/minimum/maximum number of characters.

Type check

Checks the data type of a field — ensures the input is of the correct data type (e.g. integer, real, string).

Presence check

Looks to see if any data has been entered in a field — ensures all required data has been entered and rejects blank inputs.

Format check

Ensures that data has been entered in the correct format — done using pattern matching and string handling (e.g. DD/MM/YYYY or an email address).

Check digit

A numerical value that is the final digit of a larger code, such as a barcode or ISBN. It is calculated by applying an algorithm to the code.

Double entry checking

A verification method where important data has to be entered twice in separate input boxes, then compared to ensure they both match.

Visual (screen) check

A manual verification check where the user visually checks the data on the screen and confirms it is correct before proceeding.

Parity check

A verification method used during data transmission that checks whether the number of set bits is odd or even.

Checksum

A verification method used during data transmission where a calculated value is compared to a transmitted value to detect errors.

1. Validation vs Verification

Bothvalidationandverificationare used to ensure that data entered into a computer system is correct and reasonable. The use of both is vital for the smooth running of computer systems.

Validation

Validationis performedautomatically by the computer systemto ensure that only reasonable data is accepted. It checks that data input by the usermeets specific criteria/rulesbefore processing.

Examples:range check, length check, type check, presence check, format check, check digit

Verification

Verificationis used to check that the datadoes not changeas it is being entered. It ensures that data isaccurateand is what was intended to be entered.

Examples:double entry, screen/visual check, parity check, checksum
ValidationVerification
range checkdouble entry (data entry)
length checkscreen/visual check (data entry)
type checkparity check (data transmission)
character checkchecksum (data transmission)
format check
presence check
check digits
Key difference
  • Validationensures that onlyreasonable datais accepted. It is done automatically by the computer.
  • Verificationensures that data isnot changed, either accidentally or on purpose, as it is entered. It often involves the user.
  • Both cover a variety of techniques that attempt to minimise the number of errors caused by inaccurate data.
Why validation is important

Without validation, "bad data" can enter a system and cause serious problems. For example, a user could enter:

  • A date of birth of20/13/1878(invalid month and unrealistic age)
  • A name containing numbers likeBa1
  • A city namedSandton Doll(misspelled or made up)

Validation rules help prevent such errors from being accepted.

Activity 1: Validation or Verification?

Classify each of the following as either a validation check or a verification check, and explain your reasoning.

  1. Checking that a date of birth is entered in the format DD/MM/YYYY.
  2. Asking the user to type their new password twice and comparing both entries.
  3. Checking that an age entered is between 0 and 110.
  4. Displaying all the data entered on a summary screen and asking the user to click "Submit" to confirm.
  5. Checking that a telephone number contains only digits.
  6. Checking that a barcode's final digit matches the value calculated from the other digits.
Solution:
  1. Validation(format check) — the computer automatically checks that the data follows a specific pattern.
  2. Verification(double entry) — the two entries are compared to ensure the data did not change during entry.
  3. Validation(range check) — the computer automatically checks the value falls within a reasonable range.
  4. Verification(visual/screen check) — the user manually checks the data and confirms it is correct.
  5. Validation(type/format check) — the computer automatically checks the data type of the input.
  6. Validation(check digit) — the computer calculates and compares a check digit to verify the integrity of the code.

Check Your Understanding: Validation vs Verification

Answer
  • [2 marks]Validation— an automated process where a computer checks if a user input is sensible and meets the program's requirements before it is processed
  • [2 marks]Verification— the act of checking that data is accurate when entered into a system; ensures data does not change, either accidentally or on purpose, as it is entered
Answer
  • [1 mark]Validation checks that data is reasonable and sensible (done automatically by the computer)
  • [1 mark]Verification checks that data is accurate and has not changed during entry (often involves the user)
Answer
  • [1 mark]Range check
  • [1 mark]Length check
  • [1 mark]Type check
  • [1 mark]Presence check
  • [1 mark]Format check
  • [1 mark]Check digit
Answer
  • [1 mark]Double entry checking (data entry)
  • [1 mark]Screen/visual check (data entry)
  • [1 mark]Parity check (data transmission) or checksum (data transmission)
Answer
  • [1 mark]Validation prevents "bad data" from entering a system, which could cause errors later
  • [1 mark]It makes programs more robust and user-friendly
  • [1 mark]Example: an age of 250 years old would be rejected by a range check (e.g. between 0 and 110)
Answer
  • [1 mark]A password field could have alength check(e.g. at least 8 characters), apresence check(must not be blank) and atype check(must contain both letters and numbers)
  • [1 mark]Using more than one check makes the password more secure and helps prevent weak passwords

2. Types of Validation Check (7.5a)

Validation checks are essential in computer programming to ensure that input data is accurate, reliable, and within the expected parameters. There aresix typesof validation check.

Range Check

Ensures the data entered as a number falls within a particular range.

Example:percentage marks between 0 and 100 inclusive; age between 10 and 18.

Length Check

Checks the length of a string — ensures the input includes the correct/minimum/maximum number of characters.

Example:a 4-digit PIN; a password of 8 or more characters; a car licence plate.

Type Check

Checks the data type of a field — ensures the input is of the correct data type.

Example:an age should be entered as an integer (whole number); a name should be a string.

Presence Check

Looks to see if any data has been entered in a field — ensures all required data has been entered.

Example:an email address must be given for an online transaction; reject blank inputs.

Format Check

Ensures that data entered matches a desired pattern, using pattern matching and string handling.

Example:a date in the form DD/MM/YYYY; an email address following "XXXXX@XXXXX.XXX"; a CUB number in the form CUB9999.

Check Digit

A numerical value that is the final digit of a larger code, calculated by applying an algorithm to the code.

Example:barcodes, ISBN numbers, Vehicle Identification Numbers (VIN).

More than one check

There can be occasions where more than one type of validation will be used on a field. An example of this could be a password field which could have alength,presenceandtypecheck on it.

Interactive: Try Validation Checks

Type values into the fields below to see how different validation checks work. Invalid data will be rejected with an error message.

How it works:Each field applies a different validation check. When the input passes the check, a green success message appears. When it fails, a red error message explains what is wrong.

2.1 Range Check

Arange checkensures that the input data falls within a specified range. For example, if a program asks for a person's age, you might limit entries to be between 13 and 100. This would prevent people under the age of 13 from signing up and also prevent unrealistic ages such as 250 years old.

CIE Pseudocode

OUTPUT "Please enter your age"
REPEAT
INPUT Age
IF (Age < 10) OR (Age > 18)
THEN
OUTPUT "Age must be between 10 and 18, try again."
ENDIF
UNTIL (Age >= 10) AND (Age <= 18)

Python Code

def validate_range(value, minimum, maximum):
return minimum <= value <= maximum
# Example usage
age = 26
if validate_range(age, 18, 25):
print("Age is within the valid range.")
else:
print("Age is outside the valid range.")

Real-Life Example

A student registration system requires students to register for a school event. The system uses a range check to ensure the student's age is within an acceptable range (e.g. 10 to 18 years old). If a student enters 7 or 25, the system rejects the entry.

2.2 Length Check

Alength checkensures that the length of the input data is within a specific range. For example, a password might need to be at least 8 characters long, or a PIN must be exactly 4 digits.

CIE Pseudocode

OUTPUT "Enter your code"
REPEAT
INPUT Code
IF LENGTH(Code) <> 4
THEN
OUTPUT "You must supply a 4 letter code."
ENDIF
UNTIL LENGTH(Code) = 4

Python Code

def validate_length(input_string, min_length, max_length):
return min_length <= len(input_string) <= max_length
# Example usage
name = "John Doe"
if validate_length(name, 2, 30):
print("Name length is within the valid range.")
else:
print("Name length is outside the valid range.")

Real-Life Example

When you create a new password on most websites, a length check ensures it is at least 8 characters long. When you enter a bank PIN at an ATM, a length check ensures it is exactly 4 digits.

2.3 Type Check

Atype checkensures that the input data is of the correct data type. For example, an age should be entered as an integer (whole number), not as text or a decimal.

CIE Pseudocode

OUTPUT "Enter an integer number"
REPEAT
INPUT Number
IF Number <> DIV(Number, 1)
THEN
OUTPUT "Not a whole number, please try again"
ENDIF
UNTIL Number = DIV(Number, 1)

Python Code

def validate_type(input_value, expected_type):
return isinstance(input_value, expected_type)
# Example usage
value = 42
if validate_type(value, int):
print("Value is of the correct data type.")
else:
print("Value is not of the correct data type.")

2.4 Presence Check

Apresence checkensures that some data has been entered and the value has not been left blank. For example, an email address must be given for an online transaction, and a user cannot sign up to a service if they have left the email field empty.

CIE Pseudocode

OUTPUT "Enter your name"
REPEAT
INPUT Name
IF Name = ""
THEN
OUTPUT "You must enter your name to continue."
ENDIF
UNTIL Name <> ""

Python Code

def validate_presence(input_value):
return input_value is not None and len(str(input_value).strip()) > 0
# Example usage
email = ""
if validate_presence(email):
print("Email is provided.")
else:
print("Email is missing or empty.")

2.5 Format Check

Aformat checkensures that data entered matches a desired pattern. For example, if a user is required to enter an email address, it should follow a set pattern of "XXXXX" + @ + "XXXXX" + "." + "XXX". This would allow an email address such as "example@gmail.com" to be accepted. Another example is a CUB number that must be in the form CUB9999, or a gender entry that must be M or F.

CIE Pseudocode (email format)

FUNCTION ValidateEmail(email)
IF MATCHES_PATTERN(email, "[a-zA-Z0-9]+@[a-zA-Z0-9]+[a-zA-Z]{2,}$") THEN
RETURN TRUE
ELSE
RETURN FALSE
ENDIF
ENDFUNCTION

Python Code (email format)

import re
def validate_email_format(email):
pattern = r'[a-zA-Z0-9._+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$'
return re.match(pattern, email) is not None
# Example usage
email = "example@email.com"
if validate_email_format(email):
print("Email format is valid.")
else:
print("Email format is invalid.")

2.6 Check Digit

Acheck digitis the last digit included in a code or other identification number. It is calculated from all the other digits in the code. Check digits are commonly used with:

  • Barcodes
  • ISBN numbers
  • Vehicle Identification Numbers (VIN)

Check Digit Calculation Example

Let's say the ID without the check digit is12345. To calculate the check digit:

  1. Sum of digits: 1 + 2 + 3 + 4 + 5 = 15
  2. Multiply by 7: 15 × 7 = 105
  3. Take modulus 10: 105 % 10 = 5
  4. So the complete ID with the check digit would be123455

Check Digit Validation Example

To validate the ID123455:

  1. Remove the last digit (check digit): 12345
  2. Sum of digits: 1 + 2 + 3 + 4 + 5 = 15
  3. Multiply by 7: 15 × 7 = 105
  4. Calculated check digit: 105 % 10 = 5
  5. Since the calculated check digit (5) matches the provided check digit (5), the ID is considered valid.

Activity 2: Choose the Right Validation Check

For each scenario below, state which validation check would be most appropriate and explain why.

  1. A website asks a user to enter their date of birth in the form DD/MM/YYYY.
  2. A school exam system asks for a percentage mark.
  3. A user creates a password that must be at least 8 characters long.
  4. An online form requires the user to enter their email address.
  5. A product barcode is scanned at a supermarket till.
  6. A form asks for the user's age as a whole number of years.
Solution:
  1. Format check— ensures the date follows the DD/MM/YYYY pattern.
  2. Range check— ensures the mark is between 0 and 100 inclusive.
  3. Length check— ensures the password has at least 8 characters.
  4. Presence check(and possibly format check) — ensures the email field is not left blank and follows a valid email pattern.
  5. Check digit— the barcode's last digit is validated against a calculation from the other digits.
  6. Type check— ensures the age is entered as an integer (whole number), not as text or a decimal.

Check Your Understanding: Validation Checks

Answer
  • [1 mark]A range check ensures that the data entered as a number falls within a particular range
  • [1 mark]It compares the input value against a minimum and maximum allowed value
  • [1 mark]Example: a percentage mark must be between 0 and 100 inclusive; an age must be between 10 and 18
Answer
OUTPUT "Enter your username"
REPEAT
INPUT Username
IF Username = ""
THEN
OUTPUT "No username entered, please try again"
ENDIF
UNTIL Username <> ""

Marking:OUTPUT prompt (1), REPEAT loop (1), IF check for empty string (1), UNTIL condition (1).

Answer
  • [1 mark]A check digit is the final digit of a larger code or identification number
  • [1 mark]It is calculated from all the other digits in the code using a specific formula
  • [1 mark]It is used to verify the integrity of the code — if the calculated digit matches the provided digit, the code is valid. Used with barcodes, ISBN numbers and VINs.
Answer
  • [1 mark]Presence check:checks the email field is not left blank; if empty, the user is asked to enter it again
  • [1 mark]Format check:checks the email follows a valid pattern, containing an @ symbol and a dot after it, e.g. "XXXXX@XXXXX.XXX"
  • [1 mark]Both checks together ensure that the email is provided and is in a valid format before it is accepted
Answer
  • [1 mark]Remove the check digit: 12345
  • [1 mark]Sum digits: 1+2+3+4+5 = 15; Multiply by 7: 15 × 7 = 105; Modulus 10: 105 % 10 = 5
  • [1 mark]The calculated check digit (5) does not match the provided check digit (6), so the ID123456isnot valid.
Answer
  • [1 mark]Makes the program more robust and user-friendly
  • [1 mark]Prevents further errors occurring later in the algorithm

3. Types of Verification Check (7.5b)

Verificationensures that data is not changed, either accidentally or on purpose, as it is being entered. There are several types of verification check used during data entry and data transmission.

Double Entry Checking

Important data has to be entered twice, sometimes by different people. The system then compares both entries to check they are the same before accepting the data.

Example:entering a new password twice when creating an account; entering an email address twice for a bank transaction.

Visual (Screen) Check

A manual check performed by the user who is entering the data. All the data is displayed back to the user, usually with a tick-box or button asking them to verify the data before submission.

Example:a summary page before confirming an online order; a "Please verify the data you have entered is correct before clicking submit" screen.

Parity Check

A verification method used during data transmission that checks whether the number of set bits is odd or even. A parity bit is added to make the total number of 1s either odd or even.

Example:when data is sent over a network, a parity bit helps detect if a bit has been flipped during transmission.

Checksum

A verification method used during data transmission where a calculated value (the checksum) is sent alongside the data. The receiver recalculates the checksum and compares it to the transmitted value.

Example:sending a file over the internet; if the checksums do not match, the file is corrupted and must be re-sent.

3.1 Double Entry Checking

Double entry verification is a process whereby important data has to be entered twice, sometimes by different people. The system then compares both entries to check they are the same before accepting the data.

CIE Pseudocode

REPEAT
OUTPUT "Enter your password"
INPUT Password
OUTPUT "Please confirm your password"
INPUT ConfirmPassword
IF Password <> ConfirmPassword
THEN
OUTPUT "Passwords do not match, please try again"
ENDIF
UNTIL Password = ConfirmPassword

Python Code

password = input("Enter your new password: ")
confirm = input("Please confirm your password: ")
while password != confirm:
print("Passwords do not match, please try again")
password = input("Enter your new password: ")
confirm = input("Please confirm your password: ")
print("New password accepted")

3.2 Visual (Screen) Check

A screen check or visual check is simply a manual check performed by the user who is entering the data. Once data entry is complete, all the data is displayed back to the user, usually with a tick-box or button asking them to verify the data before submission.

CIE Pseudocode

REPEAT
OUTPUT "Enter your name"
INPUT Name
OUTPUT "Your name is: ", Name, ". Is this correct? (y/n)"
INPUT Answer
UNTIL Answer = "y"

Python Code

answer = "n"
while answer != "y":
name = input("Enter your name: ")
answer = input(f"Your name is: {name}. Is this correct? (y/n): ")
print("Name confirmed.")

3.3 Parity Check and Checksum

Parity checksandchecksumsare verification methods used duringdata transmission. They help detect errors that occur when data is sent from one place to another.

MethodHow it worksUse case
Parity checkA parity bit is added to each byte so that the total number of 1s is either always odd or always even. The receiver checks the parity and flags an error if it doesn't match.Data transmitted over a network; simple error detection
ChecksumA calculated value (the checksum) is sent with the data. The receiver recalculates the checksum from the received data and compares it to the transmitted value.Sending files over the internet; verifying file integrity
Purpose of verification checks

The purpose of these verification checks is to enhance the quality and reliability of input data, reducing the likelihood of errors, inaccuracies, and inconsistencies. Visual checks catch obvious mistakes, while double entry checks provide an additional layer of validation by comparing independent entries, ensuring data integrity and reliability in critical applications.

Activity 3: Verification in Action

A user is creating an account on a website. Describe how each of the following verification methods could be used:

  1. Double entry checking
  2. Visual check

Explain why verification is important when creating a new account.

Solution:
  1. Double entry checking:The user is asked to enter their new password twice (in two separate boxes). The system compares both entries to ensure they match. If they don't, an error message is shown asking the user to try again.
  2. Visual check:After filling in all details, the user is shown a summary screen displaying all the data they entered. They must review it and click "Submit" to confirm everything is correct, or click "Edit" to go back and fix mistakes.

Why verification is important:Mistakes such as entering a password incorrectly mean being locked out of the account immediately. Verification ensures the user can access their account later, and that important details (like email or address) are correct.

Check Your Understanding: Verification Checks

Answer
  • [1 mark]Important data has to be entered twice
  • [1 mark]Sometimes by different people
  • [1 mark]The system then compares both entries to check they are the same before accepting the data; if they do not match, an error message is shown
Answer
  • [1 mark]A visual check is a manual check performed by the user who is entering the data
  • [1 mark]All the data is displayed back to the user, usually with a tick-box or button asking them to verify before submission
  • [1 mark]It is used at the end of data entry, for example on a summary/confirmation page before an online order is placed
Answer
  • [1 mark]When data is transmitted, bits can be flipped or lost due to interference
  • [1 mark]A parity bit is added to make the total number of 1s either always odd or always even
  • [1 mark]The receiver checks the parity and can detect if an error has occurred during transmission
Answer

Validation check:

  • [1 mark]Description: to test if the data entered is possible / reasonable / sensible
  • [1 mark]Example: a range check tests that data entered fits within specified values (e.g. age between 0 and 110)

Verification check:

  • [1 mark]Description: to test if the data input is the same as the data that was intended to be input
  • [1 mark]Example: a double entry check expects each item of data to be entered twice and compares both entries to check they are the same
Answer
REPEAT
OUTPUT "Enter your new password"
INPUT Password
OUTPUT "Please confirm your password"
INPUT ConfirmPassword
IF Password <> ConfirmPassword
THEN
OUTPUT "Passwords do not match, please try again"
ENDIF
UNTIL Password = ConfirmPassword
OUTPUT "New password accepted"

Marking:REPEAT loop (1), input both passwords (1), IF comparison (1), error message and UNTIL condition (1).

Answer
  • [1 mark]Validation ensures the data entered is sensible — for example, the account number is the correct length and contains only digits
  • [1 mark]Verification ensures the data has not changed during entry — for example, double entry of the account number to catch typing mistakes
  • [1 mark]Together they reduce the risk of errors, fraud and failed transactions, which is critical in banking

4. Worked Examples & Past Paper Practice

Worked Example: Validation and Verification

Describe the purpose of validation and verification checks during data entry. Include an example for each. [4 marks]

Show Mark Scheme

Answer:

Validation check:

  • [1 mark]Description: to test if the data entered is possible / reasonable / sensible
  • [1 mark]Example: a range check tests that data entered fits within specified values (e.g. 0-100); length/type/presence/format are also acceptable

Verification check:

  • [1 mark]Description: to test if the data input is the same as the data that was intended to be input
  • [1 mark]Example: a double entry check expects each item of data to be entered twice and compares both entries to check they are the same; visual check is also acceptable

Past Paper Question: Validation Methods

A school uses a computer system to record student information. The system asks for the following data:

  • Student name
  • Date of birth (DD/MM/YYYY)
  • Age (between 10 and 18)
  • Email address
  • Student ID (5 digits)

For each field, state one type of validation check that should be applied and explain why it is appropriate.

Show Mark Scheme

Answer:
FieldValidation checkWhy appropriate
Student namePresence checkEnsures the student's name is not left blank — every student must have a name recorded.
Date of birthFormat checkEnsures the date follows the DD/MM/YYYY pattern, preventing ambiguous or incorrectly formatted dates.
AgeRange checkEnsures the age is between 10 and 18 — the acceptable range for the school's students.
Email addressFormat checkEnsures the email follows a valid pattern (contains @ and a dot after it), so it can be used for communication.
Student IDLength check (and/or check digit)Ensures the ID is exactly 5 digits; a check digit could verify the ID's integrity.

Key Takeaways

  • Validationis an automated process where the computer checks that data is sensible and meets the program's requirements before processing.
  • Verificationchecks that data is accurate and has not changed, either accidentally or on purpose, as it is entered.
  • The six types ofvalidation checkare: range, length, type, presence, format and check digit.
  • Arange checkensures a numeric value falls within a specified range (e.g. 0–100 for a percentage).
  • Alength checkensures input has the correct/minimum/maximum number of characters (e.g. a 4-digit PIN).
  • Atype checkensures input is of the correct data type (e.g. an age must be an integer).
  • Apresence checkensures a field is not left blank (e.g. an email address must be entered).
  • Aformat checkensures input matches a desired pattern (e.g. DD/MM/YYYY or an email address).
  • Acheck digitis calculated from a code and used to verify the code's integrity (e.g. barcodes, ISBN).
  • The mainverification methodsare double entry checking, visual/screen check, parity check and checksum.
  • Double entryrequires important data to be entered twice and compared for consistency.
  • Avisual checkdisplays data back to the user for confirmation before submission.
  • Parity checksandchecksumsare used during data transmission to detect errors.
  • Together, validation and verification make programs more robust, user-friendly and reliable, minimising errors caused by inaccurate data.

Question Bank

Answer
  • [2 marks]Validation— an automated process where a computer checks if a user input is sensible and meets the program's requirements
  • [2 marks]Verification— checking that data is accurate when entered and does not change as it is entered
  • [1 mark]Key difference: validation ensures data isreasonable; verification ensures data isaccurateand unchanged
Answer
  • [2 marks]Range check— ensures data entered as a number falls within a particular range (e.g. 0–100)
  • [2 marks]Length check— ensures the input has the correct/minimum/maximum number of characters (e.g. 4-digit PIN)
  • [2 marks]Type check— ensures the input is of the correct data type (e.g. integer)
  • [2 marks]Presence check— ensures a field has not been left blank
  • [2 marks]Format check— ensures data matches a desired pattern (e.g. DD/MM/YYYY)
  • [2 marks]Check digit— a final digit calculated from the code to verify its integrity (e.g. barcode, ISBN)
Answer
OUTPUT "Enter a number between 0 and 100"
REPEAT
INPUT Number
IF Number < 0 OR Number > 100
THEN
OUTPUT "Number is not between 0 and 100, please try again"
ENDIF
UNTIL Number >= 0 AND Number <= 100

Marking:OUTPUT prompt (1), REPEAT loop (1), IF check with correct conditions (1), UNTIL condition (1).

Answer
  • [1 mark]A check digit is the final digit of a larger code, calculated from all the other digits
  • [1 mark]Example calculation: sum of digits (1+2+3+4+5 = 15), multiply by 7 (15 × 7 = 105), modulus 10 (105 % 10 = 5)
  • [1 mark]So the complete ID with the check digit would be 123455
  • [1 mark]To validate: the same calculation is performed on the first digits and compared to the check digit. If they match, the code is valid.
Answer
  • [2 marks]Double entry checking— important data is entered twice and the system compares both entries to ensure they match. Useful for passwords and bank details where mistakes are costly.
  • [2 marks]Visual/screen check— all data is displayed back to the user who confirms it is correct before submission. Useful for catching obvious mistakes before data is saved.
Answer
OUTPUT "Please enter your 4 digit bank PIN number"
REPEAT
INPUT Pin
IF LENGTH(Pin) <> 4
THEN
OUTPUT "Your pin number must be four characters in length, please try again"
ENDIF
UNTIL LENGTH(Pin) = 4

Marking:OUTPUT prompt (1), REPEAT loop (1), LENGTH check (1), UNTIL condition (1).

Answer
  • [1 mark]A parity bit is added to each byte/character to make the total number of 1s either always odd (odd parity) or always even (even parity)
  • [1 mark]The receiver counts the 1s in the received data and checks whether the parity matches
  • [1 mark]If the parity does not match, an error has occurred during transmission
  • [1 mark]This method can detect single-bit errors (but not all multi-bit errors)
Answer
OUTPUT "Please enter your age"
REPEAT
INPUT Age
IF Age <> DIV(Age, 1) THEN
OUTPUT "Age must be a whole number, try again."
ENDIF
IF (Age < 10) OR (Age > 18) THEN
OUTPUT "Age must be between 10 and 18, try again."
ENDIF
UNTIL (Age = DIV(Age, 1)) AND (Age >= 10) AND (Age <= 18)

Marking:OUTPUT prompt (1), REPEAT loop (1), type check using DIV (1), range check (1), error messages (1), UNTIL condition combining both (1).