Feb Revision2 QP
Feb Revision2 QP
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 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.
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
[6]
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.
[2]
[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.
[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.
[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.
[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.
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.
ii. Describe the decision that is made in this procedure and how the decision affects the flow through the
procedure.
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.
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.
Fig. 1.1
Identify three inputs that the user will have to enter to start, and / or play the game.
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]
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.
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.
Decomposition
[1]
(b). Mary has developed the program and is considering using performance modelling before installing the
system.
[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.
[2]
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.
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.
[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.
ii. Identify two outputs that the software will need to produce.
The arrays that are passed to the procedure store integer values.
length returns the total number of elements the array can hold.
[1]
[3]
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.
Fig. 1
i. State three ways that Sally has made use of abstraction in Fig. 1.
ii. Explain two benefits to Sally of using abstraction before creating the programming code.
procedure maths(number)
a = (number DIV 10) * 10
b = a + 10
if (number – a) >= (b – number) then
print(b)
else
print(a)
endif
endprocedure
(b).
(c).
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.
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.
procedure competitionWinner()
36. Two people play a counting game. The rules of the game are as follows:
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:
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
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:
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.
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
[1]
Difference 1
Difference 2
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 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.
[2]
41. A student writes a program to apply a symmetric encryption algorithm to work on messages of up
to 25 ASCII characters.
[2]
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
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.
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
for i = 0 to 4
x = getNextDigitInKey()
shiftRow(i,x)
next i
for i = 0 to 4
x = getNextDigitInKey()
shiftColumn(i,x)
next i
42. A program corrects the grammar in a line of text. The text is read in from a text file.
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.
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
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.
Discuss the benefits of Anna using an IDE to write and test her program rather than using a text
editor.
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:
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≡
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:
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.