←

Problem solving and programming

From Paper 2: Algorithms and programming
2(a)4 marks
procedure change(byVal a, byRef b)    a = a * 2    b = b + aendprocedure x = 3y = 4change(x, y)print(x)print(y)
State the outputs and explain the difference between passing by value and by reference.
From Paper 2: Algorithms and programming
2(b)6 marks
function power(base, exp)    if exp == 0 then        return 1    else        return base * power(base, exp - 1)    endifendfunction
Rewrite power as an iterative function and compare the two versions.
From Paper 2: Algorithms and programming
2(c)8 marks
Write a function validPassword(pw) that returns true only if the password is at least 10 characters long, contains at least one digit and at least one upper-case letter, and contains no spaces.
From Paper 2: Algorithms and programming
2(d)9 marks
Write a class Account with private attributes accountNumber and balance, a constructor, a getBalance method and a withdraw(amount) method that only allows withdrawals that do not make the balance negative. Then write a subclass SavingsAccount that adds an interestRate attribute and an addInterest method.
From Paper 2: Algorithms and programming
2(e)4 marks
Describe four features of an IDE that help programmers to find and fix errors.
From Paper 2: Algorithms and programming
2(f)3 marks
Explain the difference between local and global variables and why local variables are preferred.
From Paper 2: Algorithms and programming
4(b)4 marks
Describe a suitable data structure to store seat availability for one screening.
From Paper 2: Algorithms and programming
4(d)6 marks
Describe a test plan for findSeats, including normal, boundary and erroneous data.
From Paper 2: Algorithms and programming
4(e)8 marks
Tickets cost £12 for adults and £8 for children; screenings before 5pm are 25% cheaper; a group of 6 or more people gets £1 off each ticket. Write an algorithm to calculate the total price for a booking.
From Paper 2: Algorithms and programming
4(g)12 marks
Evaluate the use of an object-oriented approach for developing the cinema booking system.
Score 0 / 64 · 0 of 10 marked

This paper is written by Plasmo in the style of the OCR A-Level Computer Science exam. It is not a past paper and is not produced or endorsed by the exam board.

Problem solving and programming Exam Questions: OCR A-Level Computer Science | Plasmo