A Level Computer Science 9618 Paper 42, May/June 2023

Question paper and mark scheme75 marks3 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/42 · May/June 2023

Download PDF
1

A 1D array needs to store the names of 10 animals.

a

Write program code to declare the global string array Animals to store 10 items. Save your program as Question1_J2023. Copy and paste the program code into part 1(a) in the evidence document.

[2]
b

The main program needs to store the following animals in the array: horse lion rabbit mouse bird deer whale elephant kangaroo tiger Write program code to store these animal names in the array. The names must be in lower case and stored in the order given in the list. Save your program. Copy and paste the program code into part 1(b) in the evidence document.

[2]
c

The following pseudocode procedure sorts the array into a descending alphabetical order using only the first character in each animal name. The function LENGTH(DataArray) returns the number of elements in the array DataArray. The function MID(String, Start, Quantity) returns Quantity number of characters from String starting at index Start. The first character in the string is index 0, for example: MID("tiger", 0, 2) will return "ti" There are four incomplete statements in the procedure. PROCEDURE SortDescending() DECLARE ArrayLength : INTEGER DECLARE Temp : STRING ArrayLength LENGTH(Animals) FOR X 0 TO ArrayLength - 1 FOR Y ……………… TO ArrayLength - X - 1 IF MID(Animals[Y], 0, 1) < MID(Animals[………………], 0, 1) THEN Temp Animals[………………] Animals[Y] Animals[Y + 1] Animals[Y + 1] ……………… ENDIF NEXT Y NEXT X ENDPROCEDURE Write program code for the procedure SortDescending(). Save your program. Copy and paste the program code into part 1(c) in the evidence document.

[6]
d(i)

Write program code to amend the main program to: • call the procedure SortDescending() • output the sorted contents of the array with each animal name on a new line. Save your program. Copy and paste the program code into part 1(d)(i) in the evidence document.

[3]
d(ii)

Test your program. Take a screenshot of the output. Save your program. Copy and paste the screenshot into part 1(d)(ii) in the evidence document.

[1]
2

A business sells a single product. Customers can purchase one or more of this product. Each sale has an ID and a quantity, for example "ABC" and 2 The business needs a program to store the data about the sales in a circular queue data structure.

a

Write program code to declare a record structure, SaleData, to store the data about each sale. Save your program as Question2_J2023. Copy and paste the program code into part 2(a) in the evidence document.

[2]
b

Write program code to: • declare a global array, CircularQueue, of 5 items to store the sale records • declare the global pointers Head and Tail • declare the global variable NumberOfItems • initialise all elements of the array CircularQueue to an empty record, where the ID is null ("") and quantity is -1 • initialise Head, Tail and NumberOfItems to 0 Save your program. Copy and paste the program code into part 2(b) in the evidence document.

[4]
c

The function Enqueue(): • takes a new record as a parameter • inserts the record in the circular queue at the element pointed to by Tail • updates pointers and other variables as required • returns −1 if the circular queue is full • returns 1 if the record is stored successfully. Write program code for the function Enqueue(). Save your program. Copy and paste the program code into part 2(c) in the evidence document.

[6]
d

The function Dequeue(): • returns a null or empty record if the circular queue is empty • returns the first record in the queue if the circular queue is not empty • updates pointers and other variables as required. Write program code for the function Dequeue(). Save your program. Copy and paste the program code into part 2(d) in the evidence document.

[6]
e

The procedure EnterRecord(): • takes an ID and quantity as input and creates a sale record • uses Enqueue() to insert the record in the circular queue • outputs "Full" if the record was not inserted in the circular queue • outputs "Stored" if the record was inserted in the circular queue. Write program code for the procedure EnterRecord(). Save your program. Copy and paste the program code into part 2(e) in the evidence document.

[5]
f(i)

The following sale records need to be entered into the program:

IDQuantity
ADF10
OOP1
BXW5
XXZ22
HQR6
LLP3

Amend the main program to: • use EnterRecord() to input the six records in the table • use Dequeue() to remove one record • output either the ID and quantity of the removed record, or an error message if the circular queue is empty • use EnterRecord() to input the record with the ID "LLP" for a second time • output the ID and quantity for all the records currently stored in the array CircularQueue. Write program code to perform these tasks. Save your program. Copy and paste the program code into part 2(f)(i) in the evidence document.

[4]
f(ii)

Test your program. Take a screenshot of the output. Save your program. Copy and paste the screenshot into part 2(f)(ii) in the evidence document.

[1]
3

A company needs a computer program to store data about its employees. Part of the program is being written using object‑oriented programming. The class Employee stores data about the employees. Each employee has an employee number, a job title and hourly pay rate. The class will also store the amount they are paid each week over a 52‑week year in a 1D array. Employee HourlyPay : REAL — stores the amount each employee gets paid each hour EmployeeNumber : STRING — stores the employee’s unique number JobTitle : STRING — stores the employee’s job title PayYear2022 : ARRAY[0:51] OF REAL — stores the amount the employee has been paid each week Constructor() — initialises HourlyPay, EmployeeNumber and JobTitle from the values passed as parameters; initialises all 52 elements in PayYear2022 to 0.0 GetEmployeeNumber() — returns the employee number SetPay() — takes the week number and number of hours worked that week as parameters; calculates and stores the pay for that week in PayYear2022 GetTotalPay() — returns the total of all the values in PayYear2022

a(i)

Write program code to declare the class Employee. You only need to declare the class and its constructor. Do not declare any other methods. Use your programming language appropriate constructor. If you are writing program code in Python, include attribute declarations using comments. Save your program as Question3_J2023. Copy and paste the program code into part 3(a)(i) in the evidence document.

[5]
a(ii)

The method GetEmployeeNumber() returns the employee number. Write program code for the method GetEmployeeNumber(). Save your program. Copy and paste the program code into part 3(a)(ii) in the evidence document.

[2]
a(iii)

The method SetPay(): • takes a week number and the number of hours worked that week as parameters • calculates the pay for that week by multiplying the hourly pay by the number of hours worked that week • stores the calculated pay in the appropriate index for that week in PayYear2022. Write program code for the method SetPay(). Save your program. Copy and paste the program code into part 3(a)(iii) in the evidence document.

[3]
a(iv)

The method GetTotalPay() returns the total of all the values in PayYear2022. Write program code for the method GetTotalPay(). Save your program. Copy and paste the program code into part 3(a)(iv) in the evidence document.

[2]
b(i)

The child class Manager inherits from the parent class Employee. A manager gets a bonus. This bonus value is a percentage, for example 10.0%. When calculating the pay, the number of hours the manager worked that week is increased by the bonus value. Manager BonusValue : REAL — stores the bonus value, for example 10.0 represents a 10.0% increase Constructor() — takes bonus value, hourly pay, employee number and job title as parameters; initialises BonusValue to its parameter value SetPay() — takes the week number and number of hours worked as parameters; increases the number of hours worked by the bonus value; calls the SetPay() method from the parent class Write program code to declare the class Manager. You only need to declare the class and its constructor. Do not declare any other methods. Use your programming language appropriate constructor. If you are writing in Python, include attribute declarations using comments. Save your program. Copy and paste the program code into part 3(b)(i) in the evidence document.

[4]
b(ii)

The Manager method SetPay() overrides the method from the parent class and: • takes the week number and number of hours worked as parameters • increases the number of hours worked by the bonus value • calls SetPay() from the parent class. Write program code for the method SetPay(). Save your program. Copy and paste the program code into part 3(b)(ii) in the evidence document.

[3]
c

The main program has a global 1D array, EmployeeArray, to store data about eight employees. Each employee is stored as an object of type Employee. The file Employees.txt stores data about the employees, in the order: • hourly pay • employee number • bonus value (where included) • job title. Only employees who are managers have a bonus value saved. For example: • The first employee is a Junior Developer, with employee number 12452 and an hourly pay of $15.22. This employee does not have a bonus value. • The third employee is an Interface Manager, with employee number 02586 and an hourly pay of $22.50. This employee has a bonus value of 5.25%. Write the main program to: • declare the array to store data about 8 employees • read in the data from the file for each employee • instantiate each employee as either Employee (if the employee does not have a bonus value) or Manager (if the employee has a bonus value). Save your program. Copy and paste the program code into part 3(c) in the evidence document.

[7]
d

The file HoursWeek1.txt stores the number of hours each employee has worked in week 1, in the order: • employee number • number of hours worked. For example, the first set of data is for employee 21548 who has worked 50.0 hours. The procedure EnterHours(): • reads in the values from the file • finds the location of each employee in EmployeeArray • calls the method SetPay() for each employee. Write program code for EnterHours(). Save your program. Copy and paste the program code into part 3(d) in the evidence document.

[4]
e(i)

The main program needs to call EnterHours() and use the method GetTotalPay() to output the employee number and total pay for each of the eight employees. Amend the main program to perform these tasks. Save your program. Copy and paste the program code into part 3(e)(i) in the evidence document.

[2]
e(ii)

Test your program. Take a screenshot of the output. Save your program. Copy and paste the screenshot into part 3(e)(ii) in the evidence document.

[1]

Mark scheme

9618/42 · May/June 2023

Download PDF

1a · 2 marks

  • 1 mark

    Global array named Animals

  • 1 mark

    10 string elements

1b · 2 marks

  • 1 mark

    Storing all 10 items in the array …

  • 1 mark

    … in the correct order and all in lower case

1c · 6 marks

  • 4 marks

    1 mark for each completed statement to MAX 4

  • 1 mark

    Use of appropriate string functions to access e.g. MID and length

  • 1 mark

    Remainder of procedure correct and following example

1d(i) · 3 marks

  • 1 mark

    calling the procedure SortDescending()

  • 1 mark

    looping through all array elements

  • 1 mark

    outputting each array element on a new line

1d(ii) · 1 mark

  • 1 mark

    1 mark for screenshot e.g.

2a · 2 marks

  • 1 mark

    Record declaration named SaleData // class declaration (and end) named SaleData…

  • 1 mark

    …SaleID declared as string, Quantity as integer in record // if a class then a constructor assigning attributes SaleID and Quantity

2b · 4 marks

  • 1 mark

    Global array CircularQueue of 5 items of type SaleData

  • 1 mark

    Global variables Head, Tail and NumberOfItems all initialised to 0

  • 1 mark

    One record declared setting ID to "" and Quantity to -1 …

  • 1 mark

    ...stored in all 5 array elements

2c · 6 marks

  • 1 mark

    Function Enqueue() header (and end) taking one parameter (type SaleData)

  • 1 mark

    Checks if queue is full …

  • 1 mark

    … and returns -1

  • 1 mark

    (otherwise) Inserts parameter to CircularQueue[Tail] …

  • 1 mark

    … increments Tail and resets to 0 if 5

  • 1 mark

    Increments number of items and returns 1

2d · 6 marks

  • 1 mark

    Function header Dequeue() (and end where appropriate)

  • 1 mark

    Checking if queue is empty…

  • 1 mark

    ….and returning appropriate empty/null record/object/list element

  • 1 mark

    (Otherwise) returning the item at Head

  • 1 mark

    Incrementing Head and changing value 0 if it is 4/5

  • 1 mark

    Decrement number of items

2e · 5 marks

  • 1 mark

    Procedure header EnterRecord (and end where appropriate) (ignore parameters)

  • 1 mark

    Takes as input an ID (string) and quantity (integer)

  • 1 mark

    Creates a record/object using inputs

  • 1 mark

    Calls Enqueue() with record as parameter and stores/uses return value

  • 1 mark

    Outputs "Full" and "Stored" in correct places

2f(i) · 4 marks

  • 1 mark

    Calling EnterRecord() 6 times before dequeue

  • 1 mark

    Calling Dequeue() and storing/using return value …

  • 1 mark

    … checking if an empty record is returned and outputting either the ID and quantity of returned record or outputting the error message if empty record

  • 1 mark

    Calling EnterRecord() again after dequeue

2f(ii) · 1 mark

  • 1 mark

    1 mark for screenshot showing: - Data for 6 records input - 5 messages stating (e.g.) stored and 1 message stating (e.g.) full - 1 output of ADF 10 (dequeued) - Repeat successful input of LLP 3 - Output of the 5 records

3a(i) · 5 marks

  • 1 mark

    Class Employee declaration (and end where appropriate)

  • 1 mark

    All 4 attributes declared with suitable data types, array with (min) 52 elements

  • 1 mark

    Constructor header within class (and end where appropriate) taking 3 parameters …

  • 1 mark

    …assigning parameters to attributes within constructor

  • 1 mark

    …initialising 52 elements of array to 0.0 within constructor

3a(ii) · 2 marks

  • 1 mark

    Get method header (and end) with no parameters …

  • 1 mark

    … returning employee number (without overriding)

3a(iii) · 3 marks

  • 1 mark

    Method header (and close) with two parameters (week number and number of hours)

  • 1 mark

    Calculates pay as number of hours (parameter) * HourlyPay (attribute)

  • 1 mark

    … stores result in correct index in PayYear2022

3a(iv) · 2 marks

  • 1 mark

    Method header (and close) and returning calculated total (ignore parameters, allow return of any reasonable attempt at calculation)

  • 1 mark

    Totalling all elements in PayYear2022

3b(i) · 4 marks

  • 1 mark

    Class Manager header (and end) inheriting from Employee

  • 1 mark

    Constructor within class (and end) taking 4 parameters…

  • 1 mark

    …calling parent class constructor with 3 values from parameters

  • 1 mark

    Declaring BonusValue (real) and assigning parameter to it within constructor

3b(ii) · 3 marks

  • 1 mark

    Method SetPay header (and end) taking 2 parameters

  • 1 mark

    Calculating hours (from parameter) * bonus as a percentage

  • 1 mark

    Overriding / calling parent SetPay with week number from parameter and updated hours as parameters

3c · 7 marks

  • 1 mark

    Opening file Employees.txt to read and closing file in an appropriate place

  • 1 mark

    Exception handling with appropriate output for opening the file

  • 1 mark

    Looping to EOF / 8 times

  • 1 mark

    (Attempting to) Read in all lines from the file for each employee

  • 1 mark

    Instantiating and storing an object of type Manager (not Employee) when bonus is included...

  • 1 mark

    …with correct read in values

  • 1 mark

    (otherwise) instantiating and storing an object of type Employee …

3d · 4 marks

  • 1 mark

    Procedure header EnterHours() (ignore parameters) and opening file to read and closing file in appropriate place

  • 1 mark

    Exception handling with appropriate output for opening file

  • 1 mark

    Looping to EOF/8 times and reading in each line

  • 1 mark

    Searching array for employee number … using GetEmployeeNumber() …calling SetPay() with the number of hours and week number 1 as parameters, for that employee in the array

3e(i) · 2 marks

  • 1 mark

    Calling EnterHours() and looping through each employee …

  • 1 mark

    … outputting the employee number and their total pay using GetTotalPay() and GetEmployeeNumber()

3e(ii) · 1 mark

  • 1 mark

    1 mark for screenshot e.g.

Questions

  1. 1
    Question 114 marks
    Mark scheme ›
  2. 2
    Question 228 marks
    Mark scheme ›
  3. 3
    Question 333 marks
    Mark scheme ›

More 9618 papers

Other papers from May/June 2023

Solve it on ExamPalStart