Revision Library

Producing Robust Programs - Worksheets, Questions and Revision

20 original exam-style questions - 11 pages of questions with a full mark scheme - free printable PDF.

Download PDFJump to mark scheme (page 12)Read the revision guide
« Previous: Programming FundamentalsNext: Boolean Logic »
Revision Library
revisionlibrary.co.uk
GCSE · Computer Science

P2.3 Producing Robust Programs

OCR J277 · Calculators not allowed · about 115 minutes
Total Marks
Name: _______________________________    Date: ____ / ____ / ______
Answer ALL questions. Show all your working.
1
A software company is developing a new app. The lead developer tells the team that the app must be 'robust'.
(a)State what is meant by a robust program.(1)
(b)Give two examples of situations, other than invalid data entry, that a robust program should be able to handle without crashing.(2)
(Total for Question 1 is 3 marks)
2
A programmer is choosing the most suitable input validation check for different fields on an online form.
(a)Which check is most suitable to make sure a UK postcode is entered in the correct pattern, e.g. SW1A 1AA?(1)
  • A) Presence check
  • B) Format check
  • C) Range check
  • D) Length check
(b)Which check ensures that a customer's date of birth field is not left empty?(1)
  • A) Presence check
  • B) Format check
  • C) Range check
  • D) Check digit
(c)A 'number of tickets' field must only accept whole numbers from 1 to 8. Which check identifies that 12 has been entered?(1)
  • A) Length check
  • B) Format check
  • C) Range check
  • D) Presence check
(Total for Question 2 is 3 marks)
3
Amara is writing a program in an IDE.
(a)Amara's program will not run. The IDE highlights a missing ENDIF and displays an error message before the program starts. State the type of error this is.(1)
(b)Amara fixes this, and the program now runs, but it displays the wrong total every time. State the type of error this is now most likely to be.(1)
(c)Explain why the IDE's syntax checker did not detect the error described in part (b).(2)
(Total for Question 3 is 4 marks)
4
A program accepts a whole number representing a student's exam mark. Valid marks are whole numbers from 0 to 100 inclusive.
(a)State the term used for realistic test data that would be expected during normal use of the program.(1)
(b)Give two boundary data values that should be used to test this input.(2)
(c)Give one example of erroneous test data for this input.(1)
(d)State why it is important to test a program using erroneous data as well as normal data.(1)
(Total for Question 4 is 5 marks)
5
A registration form has three input fields: Email address, Password (must be 8 to 16 characters), and National Insurance number (format: 2 letters, 6 digits, 1 letter, e.g. QQ123456C).
(a)State which validation check would be used to make sure the password is not shorter than 8 characters.(1)
(b)State which validation check would be used to make sure the National Insurance number matches the required pattern.(1)
(c)A user submits the form with the email address field left empty. State which validation check would detect this.(1)
(d)A user enters someone else's real National Insurance number, which matches the correct format exactly. Explain why the format check would not detect this as a problem.(2)
(Total for Question 5 is 5 marks)
6
Study the following pseudocode, which calculates the mean of five numbers stored in an array:
total <- 0
count <- 0
FOR i <- 1 TO 5
total <- total + n[i]
count <- count + 1
NEXT i
a <- total / count
OUTPUT a
(a)State two maintainability techniques, other than adding comments, that could be used to improve the readability of this code without changing what it does.(2)
(b)Rewrite the line 'a <- total / count' using a more meaningful identifier name for a.(1)
(c)The array n stores a list of numbers. Suggest one more suitable identifier name for this array.(1)
(Total for Question 6 is 4 marks)
7
Programmers can test their code at different stages of development.
(a)State the difference between iterative testing and final/terminal testing.(2)
(b)State one advantage of using iterative testing rather than relying only on final testing.(1)
(Total for Question 7 is 3 marks)
8
A bank wants to make its online banking login more secure than a password alone.
(a)Identify two authentication methods, other than a password, that the bank could add to its login process.(2)
(b)Explain how using two-factor authentication reduces the risk of a criminal accessing a customer's account, even if the criminal has stolen the customer's password.(2)
(Total for Question 8 is 4 marks)
9
Binary and denary conversions (no calculator).
(a)Convert the denary number 173 to an 8-bit binary number. Show your working.(2)
(b)Convert the 8-bit binary number 11010110 to denary.(2)
(Total for Question 9 is 4 marks)
10
Study the following algorithm, written in OCR Exam Reference Language:
total <- 0
count <- 0
numbers <- [12, 7, 25, 3, 18]
FOR i <- 0 TO 4
  IF numbers[i] > 10 THEN
    total <- total + numbers[i]
    count <- count + 1
  ENDIF
NEXT i
OUTPUT total
OUTPUT count
(a)Complete a trace table for this algorithm, showing the value of i, numbers[i], total and count for each pass of the loop.(4)
(b)State the two values output by the program.(2)
(Total for Question 10 is 6 marks)
11
A programmer is using an IDE to try to find the cause of a bug in their program.
(a)Identify two tools, other than a syntax checker, provided by an IDE that can help a programmer to find the cause of an error in their code.(2)
(b)Explain how using breakpoints together with single stepping can help a programmer to find the cause of a logic error.(3)
(Total for Question 11 is 5 marks)
12
A warehouse uses a 7-digit product code. The final digit is a check digit calculated as follows: each of the first 6 digits is multiplied by a weight (7, 6, 5, 4, 3, 2, reading left to right), the six results are added together, and the check digit is the remainder when this sum is divided by 11 (if the remainder is 10, the check digit is 0). The first 6 digits of a new product code are 3 4 5 2 1 6.
(a)Calculate the check digit for this product code. Show your working.(3)
(b)State the name of this type of validation check and give one real-world example of where a check digit is used.(2)
(Total for Question 12 is 5 marks)
13
Binary, hexadecimal and denary conversions (no calculator).
(a)Convert the 8-bit binary number 10111010 to hexadecimal.(2)
(b)Convert the hexadecimal number 3F to denary.(2)
(c)State one reason why programmers often use hexadecimal, rather than binary, to represent values such as colour codes or MAC addresses.(1)
(Total for Question 13 is 5 marks)
14
Write an algorithm, using pseudocode (OCR Exam Reference Language), that repeatedly asks the user to input a whole number from 1 to 10 inclusive. The algorithm must reject and re-ask for any number outside this range, and once a valid number has been entered, it should output that number. Any correct logic will be accepted; do not worry about minor syntax errors.
(Total for Question 14 is 5 marks)
15
Study the following algorithm, written in OCR Exam Reference Language:
count <- 0
REPEAT
  INPUT mark
  count <- count + 1
  IF mark < 0 OR mark > 100 THEN
    OUTPUT "Invalid, try again"
  ENDIF
UNTIL mark >= 0 AND mark <= 100
OUTPUT "Valid mark entered after ", count, " attempt(s)"

A user enters the following values, in order, when the program runs: -5, then 150, then 68.
(a)Complete a trace table to show the value of mark, count and any output produced for each iteration of the loop.(4)
(b)State the final message that the program outputs.(1)
(Total for Question 15 is 5 marks)
16
A programmer runs their test plan. One of the tests has failed: the expected result and the actual result produced by the program do not match. Describe the steps the programmer should take, after this failed test, to resolve the problem.
(Total for Question 16 is 3 marks)
17
An online shop is developing a website where customers enter their payment card details to make a purchase. Discuss the defensive design techniques the programmers should use, and explain why each technique is important for producing a robust and secure program.
(Total for Question 17 is 6 marks)
18
A program validates a user's age before allowing them to register for a website. A valid age must be a whole number from 16 to 65 inclusive. Complete a test plan for this validation check by giving one suitable piece of test data for each of the types below, and stating the expected outcome for each.
(a)Normal data: give a value and state the expected outcome.(2)
(b)Boundary data: give a value and state the expected outcome.(2)
(c)Erroneous data: give a value and state the expected outcome.(2)
(Total for Question 18 is 6 marks)
19
Write an algorithm, using pseudocode (OCR Exam Reference Language), that repeatedly inputs whole-number exam scores from the user. Only scores from 0 to 100 inclusive should be included in a running total. The user enters -1 to indicate they have finished entering scores. Once the user has finished, the algorithm should output the average of the valid scores that were entered (assume at least one valid score is entered). Any correct logic will be accepted; do not worry about minor syntax errors.
(Total for Question 19 is 6 marks)
20
A software company is developing a large program. Evaluate the effectiveness of using iterative testing throughout development, compared with relying only on final/terminal testing once the whole program is complete.
(Total for Question 20 is 6 marks)
Mark scheme · P2.3 Producing Robust Programs

Question 1

Question 2

Question 3

Question 4

Question 5

Question 6

Question 7

Question 8

Question 9

Question 10

Question 11

Question 12

Question 13

Question 14

Question 15

Question 16

Question 17

Question 18

Question 19

Question 20

Mark your answers

This checks your answers in your browser, stores nothing on a server and needs no account.

Question 1

3 marks
Did your answer earn the marks?

Question 2

3 marks
Did your answer earn the marks?

Question 3

4 marks
Did your answer earn the marks?

Question 4

5 marks
Did your answer earn the marks?

Question 5

5 marks
Did your answer earn the marks?

Question 6

4 marks
Did your answer earn the marks?

Question 7

3 marks
Did your answer earn the marks?

Question 8

4 marks
Did your answer earn the marks?

Question 9

4 marks
Did your answer earn the marks?

Question 10

6 marks
Did your answer earn the marks?

Question 11

5 marks
Did your answer earn the marks?

Question 12

5 marks
Did your answer earn the marks?

Question 13

5 marks
Did your answer earn the marks?

Question 14

5 marks
Did your answer earn the marks?

Question 15

5 marks
Did your answer earn the marks?

Question 16

3 marks
Did your answer earn the marks?

Question 17

6 marks
Did your answer earn the marks?

Question 18

6 marks
Did your answer earn the marks?

Question 19

6 marks
Did your answer earn the marks?

Question 20

6 marks
Did your answer earn the marks?
Mark my answers