0% found this document useful (0 votes)
210 views6 pages

2210 - 02 - Status Intermediate - Program Design 2024

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
210 views6 pages

2210 - 02 - Status Intermediate - Program Design 2024

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1

Status Intermediate: Program Design

Name: Date: Marks: /75

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]

© HEGICT 2024 2210/ P2 / Status Intermediate / Summer 2024


2
3. During the period leading up to the Christmas holidays, HimTech hires temporary staff.
Staff are hired for each of the six weeks prior to Christmas week.
Here is the pseudo-code that calculates the number of additional staff needed for each week.
01 // To Calculate the number additional staff needed
02 SET WeekNumber ← [100,80,70,60,50,40]
03 SET GoodInput ← FALSE

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]

(d) Explain the difference between parameter and argument.

………………………..……………...……………………...……………………….……….
……………………………..……………..………………………………..………………[2]

© HEGICT 2024 2210/ P2 / Status Intermediate / Summer 2024


3
4. This pseudocode algorithm is used as a validation check.
PRINT "Input a number from 1 to 5000"
REPEAT
INPUT Number
IF Number < 1 OR Number > 5000
THEN
PRINT "Invalid number, please try again"

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.

Type of Test Data 1 …………………………………...…………...………………….…………….

Test Data …………………………………………………..…..……………………………….…

Reason ……………………………………………….…………..……..………………………[2]

Type of Test Data 2 …………………………………...………….………………………………….

Test Data ……………………………………………………….…………………………………

Reason ……………………………………………………….....……..……………..…………[2]

Type of Test Data 3 …………………………………...……………..………………………………

Test Data ……………………………………………………….…………………………………

Reason ……………………………………………………….....…..…………………..………[2]

5. A subroutine is declared using pseudocode.


FUNCTION CalTaka(Dollar: REAL) RETURNS REAL
RETURN Dollar * 110.5
ENDFUNCTION
Tick (√) one box to show the named section of a program that:
(a) (i) the values of the arguments passed from the main program to a subroutine: [1]
A procedure B function

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]

© HEGICT 2024 2210/ P2 / Status Intermediate / Summer 2024


4
6. A fast food restaurant offers half-price meals if the customer is a student or has a discount card.
The offer is not valid on Saturdays.
A computer system is used to identify whether the customer can have a half-price meal.
The table identifies the three inputs to the computer system:
Input Value

A Is a student

Paper | 2
B Has a discount card
C The current day is Saturday

(a) The logic system P = (A OR B) AND NOT C is used.


(i) Complete the following logic diagram for above logic statement by drawing one logic gate in each box.

[ [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]

© HEGICT 2024 2210/ P2 / Status Intermediate / Summer 2024


5

7. (a) Explain what is meant by the term library routine.


…………………..……….……...…………………………..………..……………..……..….….
…………………….………….……...……………….………...……………….……….……….
…………………………..………………..………..………………..………..………..………[2]

Paper | 2
(b) Give two examples of uses of library routines.
…………………..…………...…………………………..………..…………..…….……..….….
…………………….……………...……………….………...………….….…………….……….
…………………..…………...…………………………..………..…………..…….……..….….
…………………….……………...……………….………...………….….…………….……….
…………………………..……………..………..……………………………..………………[2]

8. The database table, PICTURE, will contain the following fields:


Artist; Catalogue Number,Price; Sold (whether picture is already sold).
(a) (i) State what data type you would choose for each field.
Programming construct Line number(s)

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]

© HEGICT 2024 2210/ P2 / Status Intermediate / Summer 2024


6
9. The one-dimensional array StaffName[] contains the names of the staff in a department.
Another one-dimensional array StaffPhone[] contains the phone numbers for the members of staff.
A final one-dimensional array StaffOffice[] contains the office location for the members of staff.
The position of each member of staff’s data in the three arrays is the same,
for example, the member of staff in position 5 in StaffPhone[] and StaffOffice[] is the same.
Write a program that meets the following requirements:
» uses procedures to display these lists:

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]

© HEGICT 2024 2210/ P2 / Status Intermediate / Summer 2024

You might also like