9618/41

Computer Science 9618/41October/November 2022

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) · Algorithms and Abstract Data Types · File Processing and Exception Handling · Recursion

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_999

A class declaration can be used to declare a record.

If the programming language does not support arrays, a list can be used instead.

A source file is used to answer Question 1. The file is called IntegerData.txt

The text file IntegerData.txt stores 100 integer numbers between 1 and 100 inclusive. A program is required to read in this data and perform searching and sorting on the data.

(a)

Write program code to declare a global 1D array, DataArray, with space for 100 integer values.

Save your program as Question1_N22.

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

2M
(b)

The procedure ReadFile() must read in the numbers from the text file and store each one in the array. Use appropriate exception handling.

Write program code for the procedure ReadFile().

Save your program.

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

6M
(c)

The function FindValues() asks the user to enter a number to search for in the array. The number input must be a whole number between 1 and 100 inclusive. The function then returns the number of times the number input appears in the array.

Write program code for the function FindValues().

Save your program.

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

7M
(d)
(i)

Write program code to call ReadFile() and FindValues() from the main program. The return value from FindValues() must be output with an appropriate message.

Save your program.

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

3M
(ii)

Test your program using the number 61 as input.

Take a screenshot to show the output.

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

1M
(e)

The procedure BubbleSort() needs to perform a bubble sort on the array and print the contents of the sorted array.

Write program code for the procedure BubbleSort() and call it from the main program.

Save your program.

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

4M

The rest of this paper

2 more questions
  • Q2Programming Paradigms (Procedural and Object-oriented)31M
  • Q3Programming Paradigms (Procedural and Object-oriented) · Algorithms and Abstract Data Types · Recursion21M
Loading the full paper…