9618/43

Computer Science 9618/43May/June 2023

Cambridge A-Level · Practical · worked solutions for every part, with the mark scheme

3
questions
75
marks
150
minutes

Topics Programming Paradigms (Procedural and Object-oriented) · File Processing and Exception Handling · Algorithms and Abstract Data Types

Q1Programming Paradigms (Procedural and Object-oriented)File Processing and Exception HandlingAlgorithms and Abstract Data TypesFree sample

Open the evidence document evidence.doc

Make sure that your name, centre number and candidate number will appear on every page of this document. This document must contain your answers to each question.

Save this evidence document in your work area as:

evidence_ followed by your centre number_candidate number, for example: evidence_zz999_9999

One source file is used to answer Question 1 and two source files are used to answer Question 3. The files are called Data.txt, AnimalData.txt and ColourData.txt

A class declaration can be used to declare a record.

A list is an alternative to an array.

A program reads data from a file and searches for specific data.

(a)

The main program needs to read 25 integer data items from the text file Data.txt into a local 1D array, DataArray

(i)

Write program code to declare the local array DataArray

Save your program as Question1_J2023.

Copy and paste the program code into part 1(a)(i) in the evidence document.

1M
(ii)

Amend the main program to read the contents of Data.txt into DataArray

Save your program.

Copy and paste the program code into part 1(a)(ii) in the evidence document.

4M
(b)
(i)

The procedure PrintArray() takes an integer array as a parameter and outputs the contents of the array in the order they are stored.

The items are printed on the same line, for example:

10 4 5 13 25

Write program code for the procedure PrintArray()

Save your program.

Copy and paste the program code into part 1(b)(i) in the evidence document.

3M
(ii)

Amend the main program to output the contents of DataArray using the procedure PrintArray()

Save your program.

Copy and paste the program code into part 1(b)(ii) in the evidence document.

1M
(iii)

Test your program.

Take a screenshot of the output.

Save your program.

Copy and paste the screenshot into part 1(b)(iii) in the evidence document.

1M
(c)

The function LinearSearch():

  • takes an integer array and integer search value as parameters
  • counts and returns the number of times the search value is found in the array.

Write program code for the function LinearSearch()

Save your program.

Copy and paste the program code into part 1(c) in the evidence document.

3M
(d)
(i)

Amend the main program to:

  • prompt the user to input a whole number between 0 and 100 inclusive
  • read and validate the input from the user
  • call LinearSearch() with DataArray and the validated input value
  • output the result in the format:
    The number 7 is found 2 times.

Save your program.

Copy and paste the program code into part 1(d)(i) in the evidence document.

4M
(ii)

Test your program by inputting the number 12.

Take a screenshot of the output.

Save your program.

Copy and paste the screenshot into part 1(d)(ii) in the evidence document.

1M

The rest of this paper

2 more questions
  • Q2Programming Paradigms (Procedural and Object-oriented)32M
  • Q3Algorithms and Abstract Data Types · Programming Paradigms (Procedural and Object-oriented) · File Processing and Exception Handling25M
Loading the full paper…