As Compsci Mock p2
As Compsci Mock p2
1 (a) (i) Complete the following table by giving the appropriate data type in each case.
(ii) Evaluate each expression in the following table by using the initial data values shown in
part (a)(i).
Expression Evaluates to
Modified OR Index > 100
LENGTH("Student: " & Name)
INT(Index + 2.9)
MID(Name, 1, 3)
[4]
(b) Each pseudocode statement in the following table contains an example of selection,
assignment or iteration.
Put one tick (‘✓’) in the appropriate column for each statement.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [5]
(b) The algorithm requires the use of basic constructs. One of these is sequence.
Identify one other basic construct required by the algorithm and describe how it is used.
Construct ..................................................................................................................................
Use ...........................................................................................................................................
...................................................................................................................................................
[2]
Complete the table by writing the name of the life cycle stage for each activity.
[5]
Complete the table to define a test plan to thoroughly test the operation of the function.
Normal 30 TRUE
[4]
(ii) The function is to be tested on its own. When it is shown to work correctly the function
will be combined with other modules and testing will continue.
..................................................................................................................................... [1]
Module Connect() will call either Activate() or Sync(). This is decided at run-time.
Connect
T1
[5]
(b) Explain the meaning of the curved arrow symbol used in the diagram in part (a).
...................................................................................................................................................
............................................................................................................................................. [2]
START
INPUT A, B
Yes
No
END
[5]
The owner wants a program to randomly choose the ‘daily special’ sandwich.
The program designer decides to store the possible sandwich fillings in a 1D array of type string.
2 "Onion"
3 "Salmon"
4 "Anchovies"
5 "Peanut Butter"
2 "Brown"
3 "Pitta"
Both arrays may contain unused elements. The value of these will be an empty string and they
may occur anywhere in each array.
A procedure Special() will output a message giving the ‘daily special’ sandwich made from two
randomly selected different fillings and one randomly selected bread.
Unused array elements must not be used when creating the ‘daily special’ sandwich.
PROCEDURE Special()
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
ENDPROCEDURE
[7]
Describe how the design could be changed to prevent certain combinations being selected.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [2]
(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.
(i) State three items of information that the new module would need. Justify your choice in
each case.
Information ........................................................................................................................
Justification .......................................................................................................................
...........................................................................................................................................
Information ........................................................................................................................
Justification .......................................................................................................................
...........................................................................................................................................
Information ........................................................................................................................
Justification .......................................................................................................................
...........................................................................................................................................
[3]
(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 .......................................................................................................................
...........................................................................................................................................
[2]
The table show the inputs, outputs and states for this part of the program:
Complete the state‑transition diagram to represent the information given in the table.
S2
START
S1
Cancel | Re-prompt
[4]
Information for each item is stored as a single line in the Stock.txt file in the format:
<ItemNum><SupplierCode><Description>
Format Comment
unique number for each item in the range
ItemNum 4 numeric characters
″0001″ to ″5999″ inclusive
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,
otherwise returns FALSE
CheckInfo() • called with a parameter of type string representing a line of item
information
• checks to see whether the item information in the string is valid
• returns TRUE if the item information is valid, otherwise returns
FALSE
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
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.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
(c) The program contains modules SuppExists() and CheckSupplier(). These have been
written but contain errors. These modules are called from several places in the main program
and testing of the main program (integration testing) has had to stop.
Identify a method that can be used to continue testing the main program before the errors in
these modules have been corrected and describe how this would work.
Method ......................................................................................................................................
Description ................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[3]
Numeric Functions
Date Functions
Operators
Note: An error will be generated if an operator is used with a value or values of an incorrect type.
Comparison Operators
= Used to compare two items of the same type. Returns TRUE if the condition is true,
otherwise returns FALSE
>
Notes:
<
• may be used to compare types REAL and INTEGER
• may be used to compare types CHAR and STRING
>=
• case sensitive when used to compare types CHAR or STRING
• cannot be used to compare two records.
<= Examples:
• "Program" = "program" evaluates to FALSE
<> • count = 4 evaluates to TRUE when variable count contains the value 4