Question 11(d)(ii) 2023 · May-June · Paper 22 · 20 marks
Question 11
Part (d)
(ii)
Question 11
Num 1.0
...
40 REPEAT 41 CALL DisplaySqrt(Num) 42 Num Num + 1.0 43 UNTIL Num > 10 ...
50 PROCEDURE DisplaySqrt(BYREF ThisNum : REAL) 51 OUTPUT ThisNum 52 ThisNum SQRT(ThisNum) // SQRT returns the square root 53 OUTPUT " has a square root of ", ThisNum 54 ENDPROCEDURE
The pseudocode is correctly converted into program code.
Function SQRT() is a library function and contains no errors.
The program code compiles without errors, but the program gives unexpected results. These are caused by a design error. The pseudocode is converted into program code as part of a larger program.
During compilation, a complex statement generates an error.
The programmer does not want to delete the complex statement but wants to change the statement so that it is ignored by the compiler.
State how this may be achieved.
...................................................................................................................................................
.............................................................................................................................................
Question 10
6 A procedure Square() will take an integer value in the range 1 to 9 as a parameter and output a number square.
The boundary of a number square is made up of the character representing the parameter value. The inside of the number square is made up of the asterisk character (*).
Parameter value 1 2 3 4 ... 9
22 3*3 4**4 9 * * * ** * * 9 333 4**4 9 ** * *** * 9 4444 9 *** **** 9 Output 9 * * * ** * * 9 9 * * * ** * * 9 9 ** * *** * 9 9 ******* 9
The pseudocode OUTPUT command starts each output on a new line. For example, the following three OUTPUT statements would result in the outputs as shown:
OUTPUT "Hello" OUTPUT "ginger" OUTPUT "cat"
Resulting output:
Hello ginger cat
Question 11
Write pseudocode for procedure Square().
Parameter validation is not required.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
Question 12
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
....................................................................................................................................................
Question 13
Question 14
7 A computer system for a shop stores information about each customer. The items of information include name and address (both postal and email) together with payment details and order history. The system also stores the product categories they are interested in and how they would like to be contacted.
Part (a)
The shop wants to add a program module that will generate emails to be sent to customers
who may be interested in receiving details of new products.
(ii)
Identify two items of customer information that would not be required by the new module.
Justify your choice in each case.
Information ........................................................................................................................
Justification .......................................................................................................................
...........................................................................................................................................
Information ........................................................................................................................
Justification .......................................................................................................................
...........................................................................................................................................
Question 15
Part (b)
The program includes a module to validate a Personal Identification Number (PIN). This is
used when customers pay for goods using a bank card.
The table show the inputs, outputs and states for this part of the program:
Current state Input Output Next state S1 Input PIN S2 S2 Re‑input PIN Display error S2 S2 Cancel Re‑prompt S1 S2 Valid PIN Enable payment S4 S2 Too many tries Block Account S3
Complete the state‑transition diagram to represent the information given in the table.
S2
START S1
Cancel | Re-prompt
Question 16
8 A computer shop assembles computers using items bought from several suppliers. A text file Stock.txt contains information about each item.
Information for each item is stored as a single line in the Stock.txt file in the format: <ItemNum><SupplierCode><Description>
Valid item information is as follows:
Format Comment unique number for each item in the range ItemNum 4 numeric characters ″0001″ to ″5999″ inclusive
SupplierCode 3 alphabetic characters to identify the supplier of the item
Description a string a minimum of 12 characters
The file is organised in ascending order of ItemNum and does not contain all possible values in the range.
Module Description OnlyAlpha() • called with a parameter of type string (already written)
- returns TRUE if the string contains only alphabetic characters,
- checks to see whether the item information in the string is valid
- returns TRUE if the item information is valid, otherwise returns
otherwise returns FALSE CheckInfo() • called with a parameter of type string representing a line of item information
FALSE
Question 17
Part (a)
Write pseudocode for module CheckInfo().
Module OnlyAlpha() should be used as part of your solution.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Question 18
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................
Part (b)
A new module is defined as follows:
Module Description AddItem() • called with a parameter of type string representing valid information for a new item that is not currently in the Stock.txt file
- creates a new file NewStock.txt from the contents of the file
Stock.txt and adds the new item information at the appropriate place in the NewStock.txt file
As a reminder, the file Stock.txt is organised in ascending order of ItemNum and does not contain all possible values in the range.
Write pseudocode for module AddItem().
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
..................................................................................................
Reveal official mark-scheme answer
The answer for this question is in the official mark scheme: open the mark scheme.
Why this question appears here
82% assigned-topic match · Programming › Constructs
Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.
Permanent source page: Educate A Change · From 9618_s23_qp_22.pdf
