Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Skeleton Code Mock Paper

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

AQA A level Computer Science

Mock exam in preparation


Section A
You are advised to spend no longer than 20 minutes on this section.
Two numbers are amicable if the sum of their factors, including 1 but not the value itself, is equal to the
other number. For instance 220 and 284 are amicable because the sum of the factors for 220 is 1 + 2 + 4 +
5 + 10 + 11 +20 + 22 + 44 + 55 + 110 = 284 and the sum of the factors for 284 is 1 + 2 + 4 + 71 + 142 = 220.

Write a program that can takes two integers as input and determines whether or not the two numbers are
amicable.

Include the following evidence in your Electronic Answer Document


4.1 Your PROGRAM SOURCE CODE [12 Marks]
4.2 SCREEN CAPTURE showing the result of testing the program by entering the numbers 220 and 284. [1
Mark]
Section B
You are advised to spend no longer than 20 minutes on this section

Figure 1 shows a partially completed Hierarchy chart for the Skeleton Code

5.1 State the name of the identifier for the subroutine denoted by a)

State the name of the identifier for the subroutine denoted by b)

State the name of the identifier for the subroutine denoted by c) [3 marks]

5.2 State the name of an identifier for a user-defined subroutine that returns an integer value.
[1 mark]

5.3 State the name of an identifier for an array or list variable in Main [1 mark]

6.1 -

6.2 Explain the steps involved in evaluating a postfix (RPN) expression [4 marks]

6.3 What algorithm does ConvertToRPN implement? [1 mark]

6.4 What are the benefits of evaluating RPN expressions compared to infix expressions [1 mark]

6.5 In ConvertToRPN what type of data structure is Precedence [1 mark]

6.6 In ConvertToRun what type of iteration is used? [1 mark]

6.7 What is an operand? [1 mark]

6.8 What is the problem if you have a mathematical expression where you want perform the
plus operation before a multiply operation in ConvertToRPN [1 mark]

7.1 UpdateTargets implements a linear queue. A circular queue could have been used instead.
Explain why a circular queue is a better choice than a linear queue. [2 marks]

7.2 Why is a linear queue an appropriate choice in the Skeleton Code even though circular
queues are normally a better choice. [1 mark]

8.0 What does the + metacharacter do when it is used in a regular expression [1 mark]

Section C
You are advised to spend no longer than 50 minutes on this section
9 This question refers to Main
Write a procedure called DisplayInstructions that has no input parameters and is called at the
start of the game from Main. The procedure will output the following instructions:
Welcome to the Number Puzzle Game
Your goal is to create expressions that match the target numbers using the allowed
numbers.
You can use the operators +, -, *, /
Enter your expressions in infix notation

Include the following evidence in your Electronic Answer Document


9.1 Your PROGRAM SOURCE CODE [4 Marks]
9.2 SCREEN CAPTURE showing the result of testing the program [1 Mark]

10 This question refers to PlayGame


As the game stands there is no explanation as to why the player did not successfully match a target value.
This could be because
a) The infix expression is invalid
b) Numbers not in the acceptable numbers list were used
c) The evaluation of the expression did not match any target value
Modify PlayGame such that the user will get one of those three messages when they are unsuccessful in
matching to a target value.

Include the following evidence in your Electronic Answer Document


10.1 Your PROGRAM SOURCE CODE [7 Marks]
10.2 SCREEN CAPTURE showing the result of testing the program by enter the word “nonsense” as a
mathematical expression [1 Mark]

11 This question refers to Main


Add an Autopilot function that activates when the user presses enter at the prompt instead of entering an
expression. The Autopilot will randomly generate a valid mathematical expression using only numbers
from the NumbersAllowed list and the four basic arithmetic operators. Each number from the
NumbersAllowed list can only be used once. The Autopilot function will randomly decide how many
numbers to use from the NumbersAllowed list, ranging from 2 to 5.
Include the following evidence in your Electronic Answer Document
11.1 Your PROGRAM SOURCE CODE [11 Marks]
11.2 SCREEN CAPTURE showing the result of testing the program by entering an empty string at the user
prompt [1 Mark]

You might also like