2210 - 02 - Status Intermediate - Program Design 2024
2210 - 02 - Status Intermediate - Program Design 2024
1. Rio is writing a program to add up some numbers. His first attempt at the program is shown.
Paper | 2
INPUT a
INPUT b
INPUT c
f = (a + b + c)DIV 3
OUTPUT f
(a) Give two ways that the maintainability of this program could be improved.
…………………..…………...…………………………..………..…………….……..….….
…………………….……………...……………….………...……………………….……….
…………………………..……………..………..………………..………..………………[2]
(b) Rio’s program uses the addition (+) arithmetic operator. This adds together two numbers.
(i) State the purpose of each of the arithmetic operators in the table.
Arithmetic operator Purpose
+
DIV
[2]
(ii) Explain what is meant by iteration construct.
………………………..……………...……………………...……………………….……….
………………………..……………...……………………...……………………….……….
……………………………..……………..………………………………..………………[2]
2. A pseudocode algorithm that manipulates sales figures is shown.
01 Number ← 0
02 L ← 999
03 H ← 0
04
05 FOR Each Number FROM “Sales.txt DO
06 IF Number < L THEN L ← Number
07 IF Number > H THEN H ← Number
08 ENDFOR
09
10 PRINT L , “ “ , H
(i) The first four inputs from the file to the algorithm are 355,554,199, and 409.
Complete the trace table showing the execution of the pseudocode with these four inputs.
Number L H Output
[2]
(ii) State the purpose of this algorithm.
………………………………………………...………….…………………..…………....[1]
Paper | 2
04 WHILE (GoodInput=False) DO
05 OUTPUT “Please Enter Number of Staff Needed”
06 FOR Index ← 1 TO 6
07 INPUT Staff
08 IF (Staff < 0 OR Staff > WeekNumber[Index] THEN
09 Call Total(Staff)
10 OUTPUT “Total Staff is “& Total
11 GoodInput ← TRUE
12 ELSE
13 OUTPUT “Invalid Staff Input”
14 END IF
15 NEXT
13 ENDWHILE
(a) Programmers use basic programming constructs when they write code.
(i) Complete the table to identify line number(s) that illustrate an example of different programming
constructs.
Programming construct Line number(s)
A condition controlled loop
A comment
A selection construct
A subprogram call
An array declaration
A nested loop
[3]
(ii) State the data type of the variable ‘GoodInput’. ……………………………....…….…....... [1]
(iii) State the data type of the variable ‘Staff’ ……………………….………..………..…….... [1]
(b) (i) State the programing construct ‘Staff’ is used in Line 09……….…………….…….…....... [1]
(ii) What is the purpose of Staff in Line 09 …………………………….…………….…..... [1]
Tick (√) one box in each row to identify if the statement about subroutines is true or false.
Statement True False
A subroutine is called from within a program.
A subroutine is not a complete program.
A subroutine is a self-contained piece of code.
A subroutine must return a value to the code from which it was called.
[2]
(c) Explain what the terms below mean with example when used about array’s in above program.
Type……………..……………..…………………....…………..…….…………….……...[1]
Dimension………..……….…..…………………...…………...……….…………...……..[1]
Size.………………..………………………..…………..………...………...…….……....[1]
………………………..……………...……………………...……………………….……….
……………………………..……………..………………………………..………………[2]
Paper | 2
ENDIF
UNTIL Number >= 1 AND Number <= 5000
PRINT Number, " is within the correct range"
Identify three different types of test data. For each type, give an example of the test data you would use to
test this algorithm and state a reason for your choice of test.
Reason ……………………………………………….…………..……..………………………[2]
Reason ……………………………………………………….....……..……………..…………[2]
Reason ……………………………………………………….....…..…………………..………[2]
C parameter D variable
(ii) Tick (√) one box which accurately describes the use of the variable Dollar [1]
A answer B call
C parameter D response
(c) Describe, using examples, the difference between local and global variables.
…………………..…………...…………………………..………..…………….…….…..….….
…………………….……………...……………….………...………………….……….……….
…………………………..……………..………..………………..…………..………………[2]
(d) Describe two benefits of using subprograms.
…………………..…………...…………………………..…………...…………….……..….….
…………………….……………...……………….…………...……………………….……….
…………………………..……………..………..…………………..………..………………[2]
A Is a student
Paper | 2
B Has a discount card
C The current day is Saturday
[ [3]
(ii) A truth table can be produced for this logic circuit.
Describe the purpose of a truth table.
………………………………………………...………….……………………...…………....[1]
(b) State how many rows (excluding any headings) would be required in a truth table for the logic expression:
P = (A OR B) AND NOT C
………………………………………………...………….……………………...…………....[1]
(c) The restaurant needs an algorithm designing to help employees work out if a customer can have a half price
meal or not. It should:
o input required data
o decide if the customer is entitled to a discount
o output the result of the calculation.
Design the algorithm using a flowchart.
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………….……………...……………….………...………….….…………….……….
…………………………..……………..……….……………………………..………………[5]
(d) Design the Structured Diagram for the solution
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………….……………...……………….………...………….….…………….……….
…………………………..……………..……….……………………………..………………[3]
Paper | 2
(b) Give two examples of uses of library routines.
…………………..…………...…………………………..………..…………..…….……..….….
…………………….……………...……………….………...………….….…………….……….
…………………..…………...…………………………..………..…………..…….……..….….
…………………….……………...……………….………...………….….…………….……….
…………………………..……………..………..……………………………..………………[2]
Artist
Catalogue Number
Price
Sold
[2]
(ii) State which field you would choose for the primary key.….….……..…….….……..…………....[1]
(b) Complete the structured query language (SQL) to return the category number and artist for all sold picture.
SELECT Catalogue Number, Artist
....................... PICTURE
WHERE Sold = .................. [2]
(c) The following SQL statement is written to display all Artist that Sold with the Price more than 500.
SELECT ALL
FROM PICTURE
IF Price < 500 OR Sold
The SQL statement is incorrect.
Rewrite the SQL statement so that it is correct.
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………….……………...……………….………...………….….…………….……….
…………………………..……………..……….……………………………..………………[3]
Paper | 2
– staff phone numbers and names in alphabetic order of staff name
– members of staff grouped by office number
» uses a procedure to display all the details for a member of staff, with the name used as a parameter
» uses a procedure to update the details for a member of staff, with the name used as a parameter.
You must use program code with local and global variables and add comments to explain how your code
works.
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………….……………...……………….………...………….….…………….……….
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………….……………...……………….………...………….….…………….……….
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………..…………...…………………………..………..…………..…….……..….….
…………………….……………...……………….………...………….….…………….……….
…………………………..……………..……….…...………………………..………………[15]