Requirements of a program

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

Requirements of a program

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which statement best describes a requirement of a program?
A Something the program must do or provide so the problem is solved
B The programming language the program is written in
2. Which is written as a clear requirement for a school quiz program?
A The program must mark each answer as correct or incorrect
B The program should be good at quizzes
3. Which requirement is specific enough to be checked?
A The program must reject any age that is not between 11 and 18
B The program must handle ages sensibly
4. Where do the requirements of a program come from?
A Whatever the programmer finds easiest to code
B The problem to be solved and what the user needs
5. A user says: 'I need to see my total shopping bill.' What requirement follows from this?
A The program must use a FOR loop to add numbers
B The program must calculate and output the total cost of all items

Match the Pairs

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

Left columnRight column
1The program must calculate the total cost of the items in the basket. AThis describes how to code the solution, not what the program must do. It does not come from the problem or the user.
2The program should be good and easy to use. BA weak requirement: it is vague and cannot be checked or tested.
3Requirements come from the problem and the user: the user says what they need the program to do. CThe requirement is not specific. 'Fast' and 'nice' are vague and cannot be tested.
4Requirements are used later to test the program: each one can be checked against the finished program. DA teacher says: 'I need the program to store each student's mark out of 100.'
5Requirement: The program must be fast and nice. EA clear requirement: a specific statement of something the program must do.
6Requirement: The program will use a FOR loop and an array. FRequirement: reject any age below 0 or above 120. Test: enter 150 and check it is rejected.

Definitions

requirement

Fill in the Blanks

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

1.
The program ____ ask the user for a name.
2.
// R1: Age must be 0 to 120 IF Age >= 0 AND Age __ 120 THEN
3.
// Test the program against each ___________
4.
R2: The program must ______ the average.
5.
Requirements come from the problem and from the ____

Spot the Error

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

Question 1
A // Req: mark must be 0 to 100
B INPUT Mark
C IF Mark<0 AND Mark>100 THEN
D OUTPUT "Invalid"
E ENDIF
Question 2
A Problem: forgotten homework
B Req 1: show homework due today
C Req 2: let a teacher add tasks
D Req 3: be fast and easy to use
Question 3
A Problem: a school shop is slow
B Guess what the app should do
C Req 1: record each sale
D Req 2: show the total price
Question 4
A // Req: output Mark1 + Mark2
B INPUT Mark1
C INPUT Mark2
D OUTPUT Mark1 * Mark2
Question 5
A Req: age must be 11 to 16
B Test: enter 10, expect accept
C Test: enter 11, expect accept
D Test: enter 17, expect reject

Answer Key

Requirements of a program
Section A: Quick Questions
Q1
A — Something the program must do or provide so the problem is solved
Q2
A — The program must mark each answer as correct or incorrect
Q3
A — The program must reject any age that is not between 11 and 18
Q4
B — The problem to be solved and what the user needs
Q5
B — The program must calculate and output the total cost of all items
Section B: Match the Pairs
Q1
The program must calculate the total cost of the items in the basket. → A clear requirement: a specific statement of something the program must do.
Q2
The program should be good and easy to use. → A weak requirement: it is vague and cannot be checked or tested.
Q3
Requirements come from the problem and the user: the user says what they need the program to do. → A teacher says: 'I need the program to store each student's mark out of 100.'
Q4
Requirements are used later to test the program: each one can be checked against the finished program. → Requirement: reject any age below 0 or above 120. Test: enter 150 and check it is rejected.
Q5
Requirement: The program must be fast and nice. → The requirement is not specific. 'Fast' and 'nice' are vague and cannot be tested.
Q6
Requirement: The program will use a FOR loop and an array. → This describes how to code the solution, not what the program must do. It does not come from the problem or the user.
Section C: Definitions
Q1
requirement — A statement of something the program must do or provide so that the problem is solved. It is specific, comes from the problem and the user, and is used later to test the program.
Section D: Fill in the Blanks
Q1
The program must ask the user for a name.
Q2
// R1: Age must be 0 to 120 IF Age >= 0 AND Age <= 120 THEN
Q3
// Test the program against each requirement
Q4
R2: The program must OUTPUT the average.
Q5
Requirements come from the problem and from the user
Section E: Spot the Error
Q1
C — The requirement says marks outside 0 to 100 must be rejected. A mark can never be below 0 AND above 100 at once, so nothing would be rejected. It should use OR.
Q2
D — 'Fast and easy to use' is vague and cannot be tested. A requirement must be specific, for example 'open in under 3 seconds'.
Q3
B — Requirements come from the problem and from the user. The analyst should ask the staff, not guess what they want.
Q4
D — The requirement says to output the total of the two marks, which needs +. Using * multiplies them, so the program does not meet the requirement.
Q5
B — Requirements are used later to test the program. The requirement says ages must be 11 to 16, so 10 should be rejected, not accepted.