9618/21 · May/June 2023
Download PDFRefer to the insert for the list of pseudocode functions and operators. A programmer has written a program which includes the function Calculate(). When the program is run, the function returns an unexpected value.
Describe how a typical Integrated Development Environment (IDE) could be used to help debug the program to find the errors in the function Calculate().
The algorithm for function Calculate() contains the three pseudocode statements shown. Describe the error in each statement or write 'no error' if the statement contains no error. Assume any variables used are of the correct type for the given function. Statement 1: Index ← STR_TO_NUM(("27") + 2) Error .......................................................................................................................................... ................................................................................................................................................... Statement 2: Index ← STR_TO_NUM(MID("CPE1704TKS", 4, 2)) Error .......................................................................................................................................... ................................................................................................................................................... Statement 3: IF MONTH(ThisDate) > '6' THEN Error .......................................................................................................................................... ...................................................................................................................................................
The program contains variables with values as follows: Variable | Value Active | TRUE Points | 75 Exempt | FALSE Complete the table by evaluating each expression. Expression | Evaluation 1 | (Points > 99) OR Active 2 | (Points MOD 2 = 0) OR Exempt 3 | (Points <= 75) AND (Active OR Exempt) 4 | (Active OR NOT Active) AND NOT Exempt
Write expression 4 from the table in part (c)(i) in its simplest form.
A program contains an algorithm to output a string of a specified length containing identical characters.

The algorithm is described as follows: 1. prompt and input a character and store in MyChar 2. prompt and input an integer and store in MyCount 3. generate a string consisting of MyChar repeated MyCount times 4. output the string. Draw a program flowchart to represent the algorithm.
A different part of the program uses the variable StartDate. Write pseudocode statements to declare StartDate and assign to it the date corresponding to 15/11/2005. Declaration ............................................................................................................................... Assignment ...............................................................................................................................
Customers collect points every time they make a purchase at a store. A program is used to manage the points system and the table lists some of the information stored for one customer. Information | Data type required Name | String Number of points collected | Integer Date of birth | Date
Identify a suitable structure for storing the information for one customer. Explain the advantage of using this structure. Structure ............................................................................................................................ Advantage .........................................................................................................................
Describe a data structure that could be used to store the information for all customers.
Customers receive points depending on the amount they spend. The number of points depends on the band that the amount falls into: Band | Amount | Points 1 | Less than ) 2 | Between $10 and ) 3 | Over ) For example, if the amount is $99.77, this amount is in band 2 and therefore the number of points is 7 × 99, which is 693 points. The algorithm to calculate the points from a given amount is expressed as follows: • work out the appropriate band • calculate and output the number of points. Apply the process of stepwise refinement to increase the detail of the algorithm. Structure your algorithm into a sequence of five steps that could be used to produce pseudocode. Write the five steps.
Function Replace() will: 1. take three parameters: • a string (the original string) • a char (the original character) • a char (the new character) 2. form a new string from the original string where all instances of the original character are replaced by the new character 3. return the new string. Write pseudocode for function Replace().
Several companies are developing websites to market a new type of games console. The company that is first to create a website that can demonstrate the interactive features of the games console will have an advantage over the others. The requirements for the website are likely to change as more information about the features of the console are made available. One company has decided to develop their website using a program development life cycle based on the waterfall model.
Give two reasons why this may not be the most appropriate model to use in this case. Reason 1 ........................................................................................................................... Reason 2 ...........................................................................................................................
Identify a more appropriate program development life cycle model for this scenario.
The website has been running in test mode for several weeks. Identify and describe a final stage of testing that should take place before the website is made available to all customers. Stage ........................................................................................................................................ Description ................................................................................................................................
A video-conferencing program supports up to six users. Speech from each user is sampled and digitised (converted from analogue to digital). Digitised values are stored in array Sample. The array Sample consists of 6 rows by 128 columns and is of type integer. Each row contains 128 digitised sound samples from one user. The digitised sound samples from each user are to be processed to produce a single value which will be stored in a 1D array Result of type integer. This process will be implemented by procedure Mix(). A procedure Mix() will: • calculate the average of each of the 6 sound samples in a column • ignore sound sample values of 10 or less • store the average value in the corresponding position in Result • repeat for each column in array Sample The diagram uses example values to illustrate the process: [Diagram] Write pseudocode for procedure Mix(). Assume Sample and Result are global.


A school has a computerised library system that allows students to borrow books for a fixed length of time. The system uses text files to store details of students, books and loans. A new module is to be written which will generate emails to each student who has an overdue book.

Decomposition will be used to break down the problem of designing the new module into sub-problems. Identify three program modules that could be used in the design and describe their use. Module 1 ................................................................................................................................... Use ........................................................................................................................................... Module 2 ................................................................................................................................... Use ........................................................................................................................................... Module 3 ................................................................................................................................... Use ...........................................................................................................................................
The program designer produces a structure chart for the new module. Part of the structure chart is shown: [Structure Chart] Explain the relationship between the four modules shown.
Two new modules are added: Module-X() and Module-Y(). • Module-X() has no parameters. • Module-Y() will take a string and a real number as parameters and return a Boolean value. • Module-D() will call either Module-X() or Module-Y(). Draw only the part of the structure chart that represents the relationship between Module-X(), Module-Y() and Module-D().
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> Item information is as follows: Format | Comment ItemNum | 4 numeric characters | unique for each item in the range "0001" to "5999" inclusive SupplierCode | 5 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. A programmer has started to define program modules as follows: Module | Description SuppExists() (already written) | • called with a parameter of type string representing a supplier code • returns TRUE if the supplier code is already in use, otherwise returns FALSE IsNewSupp() | • called with a parameter of type string representing a new supplier code • returns TRUE if the string only contains alphabetic characters (either upper or lower case) and the supplier code is not already in use, otherwise returns FALSE
Write pseudocode for module IsNewSupp(). Module SuppExists() has already been written and should be used as part of your solution. Module SuppExists() will generate a run-time error if the given parameter is not 5 characters in length.
A new module has been defined: Module | Description CheckNewItem() | • called with a parameter of type string representing a line of item information • checks to see whether an item with the same ItemNum already exists in the file • returns TRUE if the ItemNum is not already in the file, otherwise returns FALSE Write efficient pseudocode for module CheckNewItem().
The program modules SuppExists(), IsNewSupp() and CheckNewItem() are part of a group of modules that are combined to create a complete stock control program. Each module in the program is tested individually during development and is debugged as necessary. It is then added to the program and further testing performed. Identify this method of testing.
One of the modules does not work properly when it is added to the program. Describe a testing method that can be used to address this problem so that testing can continue and other modules can be added.
A new module AddItem() will be used to add information to the Stock.txt file. State the file mode that should be used for the algorithm within this module.
A new module FindItem() searches for a given item in the Stock.txt file, which is already organised in ascending order of ItemNum. Describe how this organisation may improve the efficiency of the algorithm.






