The table below shows results from testing a program that checks visitor pass codes at a community workshop. A pass code must contain six characters and beg...

Assessment: Computer Science 4CP0 | Paper 2 Mock 01 | Written Paper 2 Subject: Computer Science - 4CP0

Question 1 Report

The table below shows results from testing a program that checks visitor pass codes at a community workshop. A pass code must contain six characters and begin with the word WK. The programmer has opened the test file in an editor because some outputs are erroneous. The program accepts a code when both rules are true.

Test numberPass code inputProgram display
1WK3814accepted
2WK72accepted
3AB3814rejected
4WK0000accepted

The condition currently used in the program is:
IF LEFT(code, 2) = "WK" OR LENGTH(code) = 6 THEN

(a) Identify the test number that shows an error in the program output. [1]
(b) Give two further pass-code inputs that should be used to test the program, including one boundary example. [2]
(c) Complete the corrected Boolean operator needed between the two tests in the condition. [1]
(d) State the correct display for test number 2 after the code has been corrected. [1]
(e) Write a suitable name for the file that could store the test data, including a file extension. [1]

Answer Details

(a) The erroneous result is the row with input WK72, identified as test number 2. [1] It begins with WK but has only four characters, so it must not be accepted.

(b) Suitable additional tests include WK123, a five-character code beginning WK [1], and WK12345, a seven-character code beginning WK. [1] These test values immediately below and above the required length of six.

(c) The corrected operator is AND. [1] Both rules must be true: the code must begin with WK and have length 6.

(d) After correction, test number 2 should display rejected. [1]

(e) A suitable test-data filename is passTests.csv. [1] The filename is meaningful and .csv is a valid file extension.

Download The App On Google Playstore

Everything you need to excel in your exams

Green Bridge CBT Mobile App
Personalized AI Learning Chat Assistant
200,000+ Exam Questions Across IGCSE, JAMB, WAEC & NECO
Over 3,900 Lesson Notes
Offline Support - Learn Anytime, Anywhere
Green Bridge Timetable
Literature Summaries & Potential Questions
Track Your Performance & Progress
In-depth Explanations for Comprehensive Learning