Refer 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.
- (a)Describe how a typical Integrated Development Environment (IDE) could be used to help debug the program to find the errors in the function Calculate().[4]
- (b)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[3]
- (c)(i)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[2]
- (c)(ii)Write expression 4 from the table in part (c)(i) in its simplest form.[1]
Mark scheme
Marking points from the official mark scheme (May/June 2023). The mark or mark type is shown in brackets.
- [4] For example: Could set a breakpoint to stop the program at a particular point / instruction then the value of variables could be checked using a report/watch window while single stepping can be used to execute one statement/line at a time. Marks available as follows: One mark for each underlined term One mark for an explanation of each term Note: max 4 marks
- [3] One mark for correct description of: Error 1: Brackets mismatch // 2/value should be added after brackets/function // Addition between a string and a number is not valid // STR_TO_NUM / the function needs to be passed a string / not an integer Error 2: No Error Error 3: MONTH () returns an integer and this is being compared with a character/string // Integer cannot be compared to a string // 6 should not be in quotes
- [2] Expression Evaluation 1 (Points > 99) OR Active TRUE 2 (Points MOD 2 = 0) OR Exempt FALSE 3 (Points <= 75) AND (Active OR Exempt) TRUE 4 (Active OR NOT Active) AND NOT Exempt TRUE One mark for any two rows correct Two marks for all rows correct
- [1] NOT Exempt
Write your answer and get it marked
On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.
Sign up free →