A Level Computer Science 9618 Paper 21, Oct/Nov 2024

Question paper and mark scheme75 marks8 questions

Solve it on ExamPal

Practise

Untimed. Write on the paper and check as you go.

Start

Exam

Timed, with a clock you set, like sitting the real paper.

Start

Opens full screen.

Papers open in

Opening the question paper

Read as textThe questions and the mark scheme as plain text. Easier to read on a phone.

Question paper

9618/21 · Oct/Nov 2024

Download PDF
1

Refer to the insert for the list of pseudocode functions and operators. 1 A program will calculate the tax payable based on the cost of an item. Calculations will occur at many places in the program and these involve the use of one of three tax rates. Tax rate values represent a percentage. For example, a tax rate value of 5.23 represents 5.23%. In this case, the tax payable on an item costing $100 would be $5.23. Tax rate values are used at several places within the program. One example is given in pseudocode as follows: HighRate ← FALSE CASE OF ItemCost <= 50 : TaxRate ← 3.75 // tax rate of 3.75% <= 200 : TaxRate ← 5.23 // tax rate of 5.23% > 200 : TaxRate ← 6.25 // tax rate of 6.25% HighRate ← TRUE ENDCASE TaxPayable ← ItemCost * TaxRate // tax payable

a

The pseudocode contains a logical error. Identify the error and suggest a correction. Error .......................................................................................................................................... ................................................................................................................................................... Correction ................................................................................................................................. ...................................................................................................................................................

[2]
b(i)

During the design of the program, tax rate values have been used wherever they are needed as shown in the pseudocode example above. Tax rates do not change while the program runs. Identify a more appropriate way of representing the tax rate values in the final program.

[1]
b(ii)

Describe the benefits of your answer to part (b)(i) with reference to this program.

[3]
c

Give the appropriate data type for the variables in the following table, as used in the pseudocode:

Variable nameData type
HighRate
TaxPayable
[2]
d

The final CASE condition (> 200) in the pseudocode example could be replaced with a keyword. Give the keyword.

[1]
2

2 A program uses three global integer variables HH, MM and SS to represent the current time in hours, minutes and seconds using the 24-hour clock notation. Midnight would be represented as 00:00:00 (HH:MM:SS). If the variables HH, MM and SS contained the values 16, 30 and 10 respectively, then the time would be 16:30:10 or just after 4.30 in the afternoon. A procedure Tick() will be called every second. The procedure Tick() will: • update the value in SS each time it is called • update the values in HH and MM as appropriate • call a procedure CheckAlarm() at the start of each minute • call a procedure NewDay() whenever the time reaches midnight. Complete the pseudocode for procedure Tick(). PROCEDURE Tick() .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... ENDPROCEDURE

[6]
3

3 An algorithm will output the last three lines from a text file Result.txt The lines need to be output in the same order as they appear in the file. Assume: • Three variables LineX, LineY and LineZ will store the three lines. These are of type string and all three variables have been initialised to an empty string. • The file exists and contains at least three lines.

a

The algorithm to output the lines is expressed in eight steps. Complete the steps. 1. Open the file ........................................................................... 2. Loop until ........................................................................... 3. ........................................................................... and store in ThisLine 4. Assign LineY to LineX 5. Assign LineZ to LineY 6. Assign ThisLine to LineZ 7. After the loop, ........................................................................... 8. Output LineX, LineY, LineZ

[4]
b

Explain the purpose of steps 4, 5 and 6 in the algorithm from part (a).

[1]
c

The requirement changes, and the algorithm will now output three lines from the file, starting from a given line number. The modified algorithm will be implemented as a function which will: • be called with an integer parameter representing the given line number • output three lines, starting at the given line • return TRUE if the 3 lines are output, or FALSE if it was not possible to output the 3 lines. Describe the changes that need to be made to steps 2 to 8 of the algorithm given in part (a).

[4]
4

4 A program includes the following assignment statement: Result ← STR_TO_NUM(x) / STR_TO_NUM(y) When the program evaluates the expression in the statement, it performs a calculation. Variable Result is of type real and variables x and y are of type string. Two checks are required before the calculation is performed: 1. The two strings represent valid numeric values. 2. The numeric value of string y is not zero.

a

Identify the type of error that could occur if these checks are not carried out and state a cause of this error. Type .......................................................................................................................................... ................................................................................................................................................... Cause ....................................................................................................................................... ...................................................................................................................................................

[2]
b

The designer considers implementing the checks and calculation as a module (a procedure or a function). One reason for this is that the same checks and calculations are performed at several places in the program. Give another reason why this is a suitable approach and state what is avoided by this approach. Reason ..................................................................................................................................... ................................................................................................................................................... Avoided ..................................................................................................................................... ...................................................................................................................................................

[2]
c

The module to perform the checks and calculation will be implemented as a function. The function will need to return both a real and a Boolean value. To achieve this a record type is defined in pseudocode as follows: TYPE Result DECLARE Done : BOOLEAN DECLARE Value : REAL ENDTYPE The function Evaluate() will: • take two parameters of type string representing the two numeric values • return a variable of type Result with the Done field set to FALSE if either of the following applies: ◦ at least one of the strings does not represent a valid numeric value ◦ the numeric value of the string representing value y is zero • otherwise return a variable of type Result with the Done field set to TRUE and the Value field assigned the result of the formula (based on the numeric value of the two parameters). Write pseudocode for the function Evaluate().

[6]
5

5 A software developer follows a program development life cycle. The life cycle divides the development process into various stages.

a

The following table lists some development activities. Complete the table by writing the name of the life cycle stage for each activity.

ActivityName of life cycle stage
The walkthrough method is used.
An algorithm is implemented in a programming language.
The client is interviewed about problems with the current system.
The program is modified to run on new hardware.
Records and file structures are defined.
[5]
b(i)

The program contains a validation function. The function will: • take an integer value as a parameter • return TRUE if the value is within the range 24 to 37, inclusive • otherwise return FALSE. Complete the table to define a test plan to thoroughly test the operation of the function.

Type of test dataTest data valueExpected result
Normal30TRUE
[4]
b(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. Identify the type of testing that this represents.

[1]
6

6 A factory produces food items. The items must be used within a certain number of days after their production date. The number of days is known as the shelf life. It is different for each type of item but is always a whole number in the range 1 to 21 (inclusive). The latest date that an item can be used is called the ‘use-by’ date. A program is needed to produce labels which show the ‘use-by’ date. Part of the program is a function GetDate() which will: • take two parameters: a production date and a value representing the shelf life • return the corresponding ‘use-by’ date. The program contains a global 1D array DaysInMonth of type integer which stores the number of days in each month (index 1 is January):

IndexValueComment
131
228Note: Leap years are not considered
331
430
......
1130
1231
a

An algorithm uses the array DaysInMonth to calculate a ‘use-by’ date. An alternative design would involve the use of multiple selection statements. An array-based technique is often used when there is a large number of different values to check and where no pattern exists. One advantage of using an array-based technique is the speed of execution compared to the use of multiple selection statements. Give two other advantages of using an array for this type of operation rather than a solution based on multiple selection statements. 1 ................................................................................................................................................ ................................................................................................................................................... 2 ................................................................................................................................................ ...................................................................................................................................................

[2]
b

Complete the pseudocode for the function GetDate(). Date functions from the insert should be used in your solution. FUNCTION GetDate(ProductionDate : DATE, ShelfLife : INTEGER) RETURNS DATE .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... ENDFUNCTION

[7]
7

7 A program contains six modules with headers as follows:

Pseudocode module header
PROCEDURE Connect()
FUNCTION Activate(H1 : STRING, Code : INTEGER) RETURNS BOOLEAN
FUNCTION Sync(T1 : BOOLEAN, S2 : REAL) RETURNS INTEGER
PROCEDURE Initialise(BYREF ID : INTEGER, BYVAL CC : INTEGER)
FUNCTION Reset(RA : STRING) RETURNS INTEGER
FUNCTION Enable(SA : INTEGER) RETURNS BOOLEAN

Module Connect() will call either Activate() or Sync(). This is decided at run-time.

Figure 1 of 1 for question 7
a

Complete the structure chart for these modules.

[5]
b

Explain the meaning of the curved arrow symbol used in the diagram in part (a).

[2]
8

8 An exam paper has a maximum of 75 marks. One of five pass grades (A to E) is assigned, depending on the mark obtained. The lowest mark for a given grade is known as the grade boundary. For example, if the grade boundary for an A grade is 65 marks, then any candidate who achieves a mark of 65 or above will be awarded an A. A grade of U is awarded for marks below the E grade boundary. The five grade boundaries are stored in a global 1D array GradeBoundary of type integer. For example:

ElementValueComment
GradeBoundary[1]65The minimum mark for an A grade.
GradeBoundary[2]57The minimum mark for a B grade.
GradeBoundary[3]43The minimum mark for a C grade.
GradeBoundary[4]35The minimum mark for a D grade.
GradeBoundary[5]27The minimum mark for an E grade.

A global 2D array Result of type integer contains candidate marks for the exam. Each row relates to one candidate. Column 1 contains the candidate mark and column 2 contains the unique candidate ID. For example, for the fourth and fifth candidates:

ElementMarkElementID
Result[4, 1]56Result[4, 2]1074832
Result[5, 1]54Result[5, 2]2573839

There are more rows in the array than candidates who sit the exam. Any unused rows will be at the end of the array. Candidate papers that are given a mark within two marks of any grade boundary must be checked. For example, given the values in the example grade boundaries above, any paper that was awarded between 41 and 45 marks (inclusive) would need to be checked. A program is being written to identify papers that need to be checked. The programmer has defined the first program module as follows:

ModuleDescription
CheckMark()• called with a parameter of type integer representing a candidate mark<br>• returns TRUE if the mark is within 2 of any of the five grade boundaries, otherwise returns FALSE
a

Write pseudocode for module CheckMark().

[6]
b

A second module is defined:

ModuleDescription
CheckAll()• called with a parameter of type integer representing the number of candidate marks in the Result array<br>• uses CheckMark() to check each candidate mark<br>• for each paper that needs to be checked, write the corresponding candidate ID on a separate line in a new file named GRList.txt<br>• outputs a message with a count of how many papers need to be checked

Write pseudocode for module CheckAll(). CheckMark() must be used to check each individual mark.

[8]
c

The requirement changes. Instead of a new file, the module described in part (b) needs to add the corresponding candidate ID for each paper that needs to be checked to an existing file. Explain the change that will need to be made to CheckAll().

[1]

Mark scheme

9618/21 · Oct/Nov 2024

Download PDF

1a · 2 marks

  • 1 mark

    Error: The calculation of TaxPayable is incorrect

  • 1 mark

    Correction: TaxPayable  (ItemCost * TaxRate) / 100

1b(i) · 1 mark

  • 1 mark

    Use constants (to represent the tax rate values)

1b(ii) · 3 marks

  • 1 mark

    Tax rates are entered once only

  • 1 mark

    Avoids / Minimise (input) error(s) / changing the Tax rates accidentally // avoids different values for tax rates at different points in the program

  • 1 mark

    When required, the constant value (representing a tax rate) is changed (once) // Easier to maintain / update the program (when the tax rates change)

1c · 2 marks

  • 1 mark

    HighRate: Boolean

  • 1 mark

    TaxPayable: Real

1d · 1 mark

  • 1 mark

    OTHERWISE

2 · 6 marks

  • 1 mark

    Increment SS anywhere in the code

  • 1 mark

    Call CheckAlarm() when SS is set to zero

  • 1 mark

    Test if SS = 60 anywhere in the code …

  • 1 mark

    set SS to 0 and increment MM

  • 1 mark

    When MM is set to 60 set MM to 0 and increment HH

  • 1 mark

    When HH is set to 24 set HH to 0 and call NewDay()

3a · 4 marks

  • 1 mark

    Open the file (Result.txt) in read mode

  • 1 mark

    Loop until EOF(Result.txt) // EOF // end of file

  • 1 mark

    Read a / the / next line (from the file) and store in ThisLine and reassign LineX, LineY, LineZ

  • 1 mark

    After the loop, close the file (Result.txt) and Output LineX, LineY, LineZ

3b · 1 mark

  • 1 mark

    (Ensuring) the lines are output in correct order // Ordering the last three lines // Ordering the lines so they are in the same order as (they occur) in the file

3c · 4 marks

  • 1 mark

    Loop until given line number (-1) / <parameter> (-1) (lines have been read)

  • 1 mark

    ... if end of file is reached then return FALSE

  • 1 mark

    Loop for three lines // Read three lines // Repeat of 4 and 5 for three lines to read a line and output it

  • 1 mark

    After outputting the (required) lines return TRUE (ordering of lines no longer needed)

4a · 2 marks

  • 1 mark

    Type: Run-time error

  • 1 mark

    Cause: A divide by zero operation is attempted // Attempt to convert a non-numeric string to a number

4b · 2 marks

  • 1 mark

    Reason: This part of the algorithm performs a specific task // if the check or calculation is changed it is changed only once // A (similar) subroutine is already available // Library routine is already available // The program is simplified / easier to understand / easier to design / code / test / debug / maintain

  • 1 mark

    Avoided: Unnecessary code duplication // Errors caused by differences where several copies of the check and calculation exist

4c · 6 marks

  • 1 mark

    Function heading, parameters, ending

  • 1 mark

    ... Correct return type of Result

  • 1 mark

    Local declaration of type Result

  • 1 mark

    Attempt at using IS_NUM() to check both parameters/strings

  • 1 mark

    Attempt at using of STR_TO_NUM() to convert both parameters/strings

  • 1 mark

    Check if the divisor, is non-zero ... … and if so correct calculation and assignment to Value field and return variable of type Result having assigned both fields

5a · 5 marks

  • 1 mark

    The walkthrough method is used. : Testing

  • 1 mark

    An algorithm is implemented in a programming language. : Coding

  • 1 mark

    The client is interviewed about problems with the current system. : Analysis

  • 1 mark

    The program is modified to run on new hardware. : Maintenance

  • 1 mark

    Records and file structures are defined. : Design

5b(i) · 4 marks

  • 1 mark

    Abnormal: 12 (< 23) -> FALSE

  • 1 mark

    Abnormal / Boundary / Extreme: 23 -> FALSE

  • 1 mark

    Boundary / Extreme: 24 -> TRUE // Boundary: 25 -> TRUE // Boundary: 36 -> TRUE // Boundary /Extreme: 37 -> TRUE

  • 1 mark

    Abnormal / Boundary / Extreme: 38 -> FALSE // Abnormal: 99 (> 38) -> FALSE

5b(ii) · 1 mark

  • 1 mark

    Integration (testing)

6a · 2 marks

  • 1 mark

    Fewer lines of code are needed // The program is simpler/ less complex // Program is easier to design / code / maintain / modify / test / debug

  • 1 mark

    Direct access to days in a month / data (using month number as index) // Can use index / month to (directly) access days in month / data

6b · 7 marks

  • 1 mark

    Declare three variables of TYPE INTEGER to store DD, MM and YY

  • 1 mark

    Correct use of date functions from Insert to extract three integer values representing DD, MM and YY and use/assign to a variable

  • 1 mark

    Add parameter ShelfLife to DD and use / assign result to a variable

  • 1 mark

    Extract LastDay from DaysInMonth using MM as Index

  • 1 mark

    Test for new DD after end of month / DaysInMonth[MM] and if DD > DaysInMonth[MM]: MM is incremented by 1 and DD is set to DD – DaysInMonth[MM]

  • 1 mark

    If MM = 13 / MM > 12 then increment YY and set MM to 1

  • 1 mark

    Use of SETDATE to assign value to NewDate, NewDate must have been delared as a type DATE and return date

7a · 5 marks

  • 1 mark

    All module identified in correct hierarchy

  • 1 mark

    Parameters to both Sync and Activate and return values

  • 1 mark

    Parameters to both Reset and Enable

  • 1 mark

    Parameters to Initialise

  • 1 mark

    Decision diamond

7b · 2 marks

  • 1 mark

    reference to iteration

  • 1 mark

    naming all three modules correctly including correct sequence of calls

8a · 6 marks

  • 1 mark

    Loop through all elements in GradeBoundary array // Correct syntax used for selection structure(s)

  • 1 mark

    Attempt to calculate range, both Lower and Upper, in a loop // Correct checks for two ranges

  • 1 mark

    Completely correct range calculation in a loop // Correct checks for three ranges

  • 1 mark

    Test if given mark / parameter, is within range in a loop // Correct checks for four ranges

  • 1 mark

    Set variable / immediate RETURN if recheck required in a loop // Correct checks for all five ranges

  • 1 mark

    Return Boolean in both cases following a reasonable attempt

8b · 8 marks

  • 1 mark

    Procedure heading, parameter and ending.

  • 1 mark

    Open file in write mode and subsequently close

  • 1 mark

    Loop through all CNum candidates

  • 1 mark

    Extract candidate mark from Result array in a loop

  • 1 mark

    Use of CheckMark() with candidate mark as parameter in a loop

  • 1 mark

    Test return value and if TRUE then increment Count in a loop

  • 1 mark

    ... write ID to file ... after conversion to a string in a loop

  • 1 mark

    Final output of message giving number of papers to check not in a loop

8c · 1 mark

  • 1 mark

    The file will need to be opened in APPEND mode

Questions

  1. 1
    Question 19 marks
    Mark scheme ›
  2. 2
    Question 26 marks
    Mark scheme ›
  3. 3
    Question 39 marks
    Mark scheme ›
  4. 4
    Question 410 marks
    Mark scheme ›
  5. 5
    Question 510 marks
    Mark scheme ›
  6. 6
    Question 69 marks
    Mark scheme ›
  7. 7
    Question 77 marks
    Mark scheme ›
  8. 8
    Question 815 marks
    Mark scheme ›

More 9618 papers

Other papers from Oct/Nov 2024

Solve it on ExamPalStart