[go: up one dir, main page]

0% found this document useful (0 votes)
152 views27 pages

Feb Revision2 QP

The document describes a 2-player board game with a board stored as a 2D array. Subroutines are used in the program to benefit the programmer by making the code more organized and reusable. A weather monitoring program is described that reads temperature data from an array and outputs the number of days in each temperature band. A game keeping track of archery scores is outlined, using a 1D array to store player record structures with names and scores.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
152 views27 pages

Feb Revision2 QP

The document describes a 2-player board game with a board stored as a 2D array. Subroutines are used in the program to benefit the programmer by making the code more organized and reusable. A weather monitoring program is described that reads temperature data from an array and outputs the number of days in each temperature band. A game keeping track of archery scores is outlined, using a 1D array to store player record structures with names and scores.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

Revision Paper 2

21. The layout for a 2-player board game is shown in Fig 2.1

The game is played by rolling two 6-sided dice and moving that number of spaces. Both players start on the START space. If
a player lands on a space occupied by the other player, they move to the next available space.

The board is to be stored as a 2-dimensional array.

The programmer is using a number of subroutines in the program. Explain, using an example, the benefits to the programmer
of using subroutines in the creation of this game.

[4]

22. A meteorologist sets up a weather station to monitor temperatures throughout the year.

She classifies temperatures in one of four bands:

Band Temperature Range (degrees Celsius)

© OCR 2024. You may photocopy this Page 1 of 27 Created in ExamBuilder


page.
Band A 10 or below
Band B 11–20
Band C 21–30
Band D 31 or above

The weather station records the temperature every day as an integer. At the end of the year the temperatures are stored in
an array called temperatures.

Write a program in pseudocode that reads through this array and produces an output which shows the total number of days
within each band. An example of such an output is shown below.

Band A: 93
Band B: 143
Band C: 98
Band D: 31

Ensure your code is efficient.

[6]

© OCR 2024. You may photocopy this Page 2 of 27 Created in ExamBuilder


page.
23.

A games company has developed a game called Kidz Arrowz. The players throw an arrow at a target board and are awarded
different points depending on which circle the arrow lands. Fig. 1 shows the board.

Fig. 1

A computer program is required to keep track of the scores for each competition. The user will enter the number of
players, and the name of each player, in that competition to a maximum of 10.

i. The program will then ask for the score of each player in turn. Each competition has 8 rounds, with each player
throwing one arrow each round. The program will then display the total score of each player.

The players are declared as a record structure:

record player(string playerName, integer totalScore)

Describe what is meant by a record structure.

[2]

ii. The records for the players are stored in a 1D array.

State why a 1D array is a suitable data structure for the records.

[1]

iii. Three data structures are arrays, records and stacks.

Identify one other data structure.


© OCR 2024. You may photocopy this Page 3 of 27 Created in ExamBuilder
page.
[1]

24. A car has a feature in its engine management system that is intended to save fuel and emissions produced when the car
is waiting at traffic lights or in a traffic jam. The default option is that if the gears are disengaged and the car is not moving, the
engine is switched off. There is a display on the dashboard that indicates when the engine has been switched off in this way.

However, sometimes it is necessary to keep the engine running even when the car is stationary, in order to provide electric
power to charge the battery, run the heater, run the air conditioning system or keep the lights on. This, in turn, is affected by
the external and internal temperatures, the settings chosen by the driver and the intensity of light outside.

Identify four inputs needed by this feature of the engine management system.

For each one suggest a suitable data type for its storage.

Input Data type

[8]

25(a). The map shown below in Fig.1 is of a city and surrounding districts. The map is an abstraction made up of a
number of component parts.

Using the map in Fig.1 as an example, define the term abstraction.

[4]

(b). Both map making and program development make use of reusable components.

i. Give three examples of how reusable component parts are used in Fig.1.

© OCR 2024. You may photocopy this Page 4 of 27 Created in ExamBuilder


page.
2

[3]

ii. Explain how programmers make use of reusable components when developing large programs.

[3]

26. Fig.3 shows a plan of a cafeteria. Customers are complaining that it currently takes too long to collect their drinks.

The cafeteria manager is thinking about reorganising the layout of the cafeteria in order to speed up the service to customers.

Explain how computational methods could be used in order to improve the layout of this cafeteria.

© OCR 2024. You may photocopy this Page 5 of 27 Created in ExamBuilder


page.
[4]

27(a). A group of A-level students are working together to program a computer game.

In the game, the player controls a character who moves through a virtual world. The game starts with a load-up screen.
The player can select which area to move to on an on-screen map, and then they control the movements of their
character using a keyboard to solve puzzles on the screen.

The following pseudocode algorithm is for the sub-procedure characterMovement.

i. Identify the three parameters in the procedure characterMovement.

ii. Describe the decision that is made in this procedure and how the decision affects the flow through the
procedure.

© OCR 2024. You may photocopy this Page 6 of 27 Created in ExamBuilder


page.
[3]

iii. Explain why characterx and charactery are passed byRef and not byVal.

[3]

(b). Explain, using examples, how abstraction would be used to create the virtual world.

© OCR 2024. You may photocopy this Page 7 of 27 Created in ExamBuilder


page.
[4]

28(a). A software developer is creating a Virtual Pet game.

The user can choose the type of animal they would like as their pet, give it a name and then they are responsible
for caring for that animal. The user will need to feed, play with, and educate their pet.

The aim is to keep the animal alive and happy, for example if the animal is not fed over a set period of time then
the pet will die.

The game tells the user how hungry or bored the animal is as a percentage (%) and the animal’s intelligence is ranked as a

number between 0 and 150 (inclusive).
• Hunger and boredom increase by 1% with every tick of a timer.
• When the feed option is selected, hunger is reduced to 0.
• When the play option is selected, bored is reduced to 0.
• When the read option is selected, the intelligence is increased by 0.6% of its current value.

An example of the game is shown:

Fig. 1.1

Identify three inputs that the user will have to enter to start, and / or play the game.

(b). The developer is using decomposition to design the game.

i. Describe the process of decomposition.

© OCR 2024. You may photocopy this Page 8 of 27 Created in ExamBuilder


page.
[2]

ii. The developer has produced the following structure diagram for the game:

Complete the structure diagram for the Virtual Pet game by filling in the empty boxes.

(c). The developer made use of abstraction when creating the Virtual Pet game.

Discuss the need for and purpose of abstraction and how abstraction will be used in the development of the game.
[9]

© OCR 2024. You may photocopy this Page 9 of 27 Created in ExamBuilder


page.
29.

A country’s national rail operator wants to represent their rail network on a computer system to keep track of the
location of trains, and any problems on the network.

After studying the rail network, the operator uses abstraction to create the virtual representation.

i. Define the term ‘abstraction’.

© OCR 2024. You may photocopy this Page 10 of 27 Created in ExamBuilder


page.
[1]

ii. Identify two reasons why abstraction is needed in the rail network program.

iii. Describe one potential difference between the virtual and real rail network.

[2]

30(a). A company merger is joining five e-commerce retailers under one company, OCRRetail. Each retailer has a
different sales system and OCRRetail wants to develop one computer system that can be used by all the retailers.

Mary’s software development company has been employed to analyse and design a solution for the company.

i. Two computational methods (techniques used to solve a problem using computational thinking) that
Mary will use are problem recognition and decomposition.

State what is meant by problem recognition and decomposition.

© OCR 2024. You may photocopy this Page 11 of 27 Created in ExamBuilder


page.
Recognition

Decomposition

ii. State one additional computational method.

[1]

(b). Mary has developed the program and is considering using performance modelling before installing the
system.

i. Define the term ‘performance modelling’.

[1]

ii. Identify one way performance modelling could be used to test the new system.

[1]

(c). Mary created the program as a series of sub-programs that can be reused.

Describe one benefit of Mary creating reusable program components.

[2]

© OCR 2024. You may photocopy this Page 12 of 27 Created in ExamBuilder


page.
31(a). Janet is designing a piece of software for a furniture company.

The software will allow a user to plan the position of furniture in a room. Users will be able to set the size
and shape of a room, and then choose furniture from a library of furniture items. These pieces of furniture
will have set sizes and designs and the user will be able to view the room in 3D to see how it looks from a
variety of angles.

Janet is using computational thinking techniques during the design process.

i. Janet is removing some aspects during the design of the software to simplify it and to make it
easier to produce.

State the name of the computational thinking technique that Janet is using.

[1]

ii. The computational thinking technique in part (i) makes it easier to produce the software.

Identify one additional reason why this technique is necessary.

[1]

iii. Explain, with examples, two ways in which Janet will apply the computational thinking technique in
part (i) to this project.

(b). Janet is planning the inputs and outputs for the software.

i. Identify two inputs that the software will need to take.

© OCR 2024. You may photocopy this Page 13 of 27 Created in ExamBuilder


page.
1

ii. Identify two outputs that the software will need to produce.

32(a). A procedure is shown in the following pseudocode.

The arrays that are passed to the procedure store integer values.

length returns the total number of elements the array can hold.

01 procedure calculateOnce(data[]:byRef, nextData[]:byRef)


02 if data.length > nextData.length then
03 loopCount = nextData.length - 1
04 else
05 loopCount = Data.length - 1
06 endif
07 count = 0
08 while count <= loopCount
09 data[count] = data[count] + nextData[count]
10 count = count + 1
11 endwhile
12 endprocedure

A decision is made on line 02.

i. Identify the line where the second decision is made.

[1]

ii. Explain the purpose of the code in lines 02 to 06.

[3]

© OCR 2024. You may photocopy this Page 14 of 27 Created in ExamBuilder


page.
(b). The procedure has parameters passed by reference.

i. Give the identifiers of the two parameters.

ii. State the effect of the array data[] being passed by reference and not by value.

[1]

33. Sally is a classroom teacher. She would like a program to be able to organise where students will sit in
her classroom.

A plan of her classroom is shown in Fig. 1.

Fig. 1

i. State three ways that Sally has made use of abstraction in Fig. 1.

© OCR 2024. You may photocopy this Page 15 of 27 Created in ExamBuilder


page.
3

ii. Explain two benefits to Sally of using abstraction before creating the programming code.

34(a). Given the following procedure:

procedure maths(number)
a = (number DIV 10) * 10
b = a + 10
if (number – a) >= (b – number) then
print(b)
else
print(a)
endif
endprocedure

State the value printed by the procedure maths if number=27

(b).

State the value printed by the procedure maths if number=10

(c).

© OCR 2024. You may photocopy this Page 16 of 27 Created in ExamBuilder


page.
State the value printed by the procedure maths if number=14

35. Albert runs a competition each week in his local village hall. So that Albert can contact the
winner he would like a program for the winner to enter their telephone number which is then
checked and written into a text file.

The rules for Albert’s program are as follows:

1. The telephone number is entered. This is checked to ensure that the first digit is a 0
2. If the first digit is not a 0 then a message saying “Needs To Start With 0” is printed
If the first digit is a 0 then the telephone number is passed into a pre-existing function called checkLength as a
3.
parameter. This will return true if the length of the telephone number is long enough
4. If the telephone number is long enough then it is written into a text file called "winner.txt"
5. If the telephone number is not long enough then a message saying “Not Long Enough” is printed.

Complete the procedure competitionWinner so that it meets the rules of Albert’s program.

You should write your procedure using pseudocode or program code.

procedure competitionWinner()

© OCR 2024. You may photocopy this Page 17 of 27 Created in ExamBuilder


page.
endprocedure

36. Two people play a counting game. The rules of the game are as follows:

• The first player starts at 1


• Each player may choose one, two or three numbers on their turn and the numbers must be in ascending order
• Players take it in turns to choose
• The player who chooses “15” loses the game.

For example, if the first player chooses three numbers (1, 2, 3) then the second player could
choose one number (4), two numbers (4, 5) or three numbers (4, 5, 6). The first player then takes
another go.

Write an algorithm using pseudocode that allows two players to play this game. The algorithm
should:

• Alternate between player 1 and player 2


• Ask the player how many numbers they would like to choose, ensuring that this is between 1 and 3
• Display the numbers that the player has chosen
• Display a suitable message to say which player has won once the number 15 has been displayed.

© OCR 2024. You may photocopy this Page 18 of 27 Created in ExamBuilder


page.
[8]

37. The following pseudocode procedure performs an insertion sort on the array parameter.

01 procedure insertionSort(dataArray:byRef)
02 for i = 1 to dataArray.Length - 1
03 temp = dataArray[i]
04 tempPos = i – 1

© OCR 2024. You may photocopy this Page 19 of 27 Created in ExamBuilder


page.
05 exit = false
06 while tempPos >= 0 and exit == false
07 if dataArray[tempPos] < temp then
08 dataArray[tempPos + 1] = dataArray[tempPos]
09 tempPos = tempPos - 1
10 else
11 exit = true
12 endif
13 endwhile
14 dataArray[tempPos + 1] = temp
15 next i
16 endprocedure

State whether the procedure insertionSort sorts the data into ascending or descending
order and explain your choice.

[3]

38. George owns a small book shop. He wants a program to work out the daily sales figures.

He uses a text file called “Sales.txt” shown in Fig. 1. Each line represents the sales total for a different
day of the week. The program can run at any point during the week and therefore the text file may not
have seven lines.

2367.34

1986.92

2251.49

1882.40

2412.83

3411.32

2721.76

The program needs to read the text file and then calculate:

• The number of days that the program is calculating over


• The total sales over that period
• The average daily sales over that period

© OCR 2024. You may photocopy this Page 20 of 27 Created in ExamBuilder


page.
At the end of the text file, it should then print the results of these calculations to the screen.

When the values are being read from the Sales.txt file they will be a string data type.

In order for them to be processed they will need to be cast (i.e. converted) to a different data type.

Explain what data type the values in “Sales.txt” should be converted to.

[2]

39. A programmer creates another function to count and return how many capital letters are in a string
that is passed into the function as a parameter.

The asc() function takes in a character and returns its ASCII value. For example asc("A") returns
65. Capital letters have ASCII values between 65 and 90 inclusive.

i. Complete the function below.

function countCapitals(text)
/ initialise counter to 0
capCount = 0
/ loop through each character in the string passed in
for x = 0 to text.length-1
c = text.subString(x, 1)
/ check if character is a capital
if asc(c) >= 65 ……………………………………………………………
/ if so, increment counter
…………………………………………………………………………
endif
next x
……………………………………………………………………
endfunction

ii. Give one similarity between ASCII and Unicode.

[1]

iii. Give two differences between ASCII and Unicode.

Difference 1

Difference 2

© OCR 2024. You may photocopy this Page 21 of 27 Created in ExamBuilder


page.
40. A card game uses a set of 52 standard playing cards. There are four suits; hearts, diamonds,
clubs and spades. Each suit has a card with a number from; 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13.

The card game randomly gives 2 players 7 cards each. The unallocated cards become known as the
deck.

The players then take it in turns to turn over a card. A valid move is a card of the same suit or the
same number as the last card played.

The winner is the first player to play all of their cards.

The cards are held in the 2D array cards. The first index stores the card number and the second
index stores the suit, both as strings.

Write a pseudocode statement or program code to declare the array cards.

[2]

41. A student writes a program to apply a symmetric encryption algorithm to work on messages of up
to 25 ASCII characters.

Describe what is meant by the term ‘ASCII’.

[2]

The encryption algorithm works in the following way.


A message of up to 25 characters (spaces and punctuation are not included) is placed in a 5×5 array.
Any leftover spaces are filled with random letters. The message I LOVE COMPUTER SCIENCE
becomes:

I L O V E
C O M P U
T E R S U
I E N C E
T O W R M

The key is a sequence of ten numbers.


In this example we will use 1 2 3 4 5 1 2 3 4 5. The first 5 numbers state how many spaces
the rows 0 to 4 must be rotated right.
© OCR 2024. You may photocopy this Page 22 of 27 Created in ExamBuilder
page.
A key with the first 5 digits 1 2 3 4 5 would result in

E I L O V
P U C O M
R S C T E
E N C E I
T O W R M

The next 5 digits state how many spaces down the columns 0 to 4 should be rotated.

Applying the last 5 digits 1 2 3 4 5 to the grid above would give

T N C O V
E O C T M
P I W E E
R U L R I
E S C O M

Part of the pseudocode for the algorithm is written below.

global array grid[5,5]


addMessage()
/ letters and random letters have been entered
/ into the 2D array, grid

for i = 0 to 4
x = getNextDigitInKey()
shiftRow(i,x)
next i

for i = 0 to 4
x = getNextDigitInKey()
shiftColumn(i,x)
next i

/Now reassemble array back into string.

42. A program corrects the grammar in a line of text. The text is read in from a text file.

The function, getText, needs to:

• take the file name as a parameter


• open the file
• read the line of data in the text file into one string
• return the string of data.

Write the function getText.

© OCR 2024. You may photocopy this Page 23 of 27 Created in ExamBuilder


page.
[4]

43. A survey is carried out to look at the types of vehicle that travel down a stretch of motorway.

For each vehicle that passes by, a letter is entered into the system.

For a car ‘C’ is entered.

For a motorbike ‘M’ is entered.

For a lorry ‘L’ is entered.

For any other vehicle ‘O’ is entered.

It is decided to compress the data that has been generated.

The survey takers want to find out the longest continuous sequence of cars in any given chunk of
data. For example, in the data

CCMCCCCLLCCC

the longest sequence would be 4.

Write the function longest which takes in a string of characters as an argument and returns an
integer representing the longest continuous sequence of Cs.

44. * Anna currently writes her program code in a text editor and then runs the compiler.

© OCR 2024. You may photocopy this Page 24 of 27 Created in ExamBuilder


page.
She has been told that using an Integrated Development Environment (IDE) would be more
helpful.

Discuss the benefits of Anna using an IDE to write and test her program rather than using a text
editor.

© OCR 2024. You may photocopy this Page 25 of 27 Created in ExamBuilder


page.
[9]

45. All users of a computer system have a unique username and password. The computer
system has implemented two-factor authentication so that users must respond to either an email
or text message containing a secret code to be able to access the system.

Let:

A be a Boolean value for if a user enters a valid username

B be a Boolean value for if a user enters a password that matches their username

C be a Boolean value for if a user is able to respond to an email containing a secret code

D be a Boolean value for if a user is able to respond to a text message containing a secret code

Q be a Boolean value for if entry to the computer system is allowed

Complete the Boolean expression below:

Q≡

46. George owns a small book shop. He wants a program to work out the daily sales figures.

He uses a text file called “Sales.txt” shown in Fig. 1. Each line represents the sales total for a
different day of the week. The program can run at any point during the week and therefore the text file
may not have seven lines.

2367.34

1986.92

2251.49

1882.40

2412.83

3411.32

2721.76

The program needs to read the text file and then calculate:

• The number of days that the program is calculating over


• The total sales over that period
• The average daily sales over that period

At the end of the text file, it should then print the results of these calculations to the screen.

Write a procedure called salesAnalysis that will meet the rules of George’s program.

You should write your procedure using pseudocode or program code.

© OCR 2024. You may photocopy this Page 26 of 27 Created in ExamBuilder


page.
[7]

END OF QUESTION PAPER

© OCR 2024. You may photocopy this Page 27 of 27 Created in ExamBuilder


page.

You might also like