← Back to Dashboard

2.2 Programming

GCSE Computer Science (J277)

1. Jack’s program uses the addition (+) arithmetic operator. This adds together two numbers.
State the purpose of the arithmetic operators * and /
[2]
Login to save your answers
/ 2
2. Tick one box in each row to identify whether the OCR Reference Language code given is an example of selection or iteration.
[4]
OCR Reference Language code Selection Iteration
for i = 1 to 10
while score != 0
if playerHit() then
switch bonus: case 0: score = 9
/ 4
3. Write pseudocode to increment the value held in the variable score by one.
[1]
Login to save your answers
/ 1
4. Each member of staff that works in the restaurant is given a Staff ID. This is calculated using the following algorithm. Define the term casting and give the line number where casting has been used in the algorithm.
[2]
Question Image
Login to save your answers
/ 2
5. Jack decides to improve his program. He wants to be able to input how many numbers to add together each time the algorithm runs, and also wants it to calculate and display the average of these numbers.
Write an algorithm to:
• ask the user to input the quantity of numbers they want to enter and read this value as
input
• repeatedly take a number as input, until the quantity of numbers the user input has
been entered
• calculate and output the total of these numbers
• calculate and output the average of these numbers.
[6]
Login to save your answers
/ 6
6. Customers at a hotel can stay between 1 and 5 (inclusive) nights and can choose between a basic room or a premium room. A typical booking record is shown in the table:
State the most appropriate data type for the following fields: Nights and Room
[2]
Question Image
Login to save your answers
/ 2
7. A Basic room costs £60 each night. A Premium room costs £80 each night.
a) Create a function, newPrice(), that takes the number of nights and the type of room as parameters, calculates and returns the price to pay. You do not have to validate these parameters.
You must use either:
• OCR Exam Reference Language, or
• a high-level programming language that you have studied
[4]
Login to save your answers
/ 4
b) Write program code, that uses newPrice(), to output the price of staying in a Premium room for 5 nights.

You must use either:
• OCR Exam Reference Language, or
• a high-level programming language that you have studied
[3]
Login to save your answers
/ 3
8. The hotel car park charges £4 per hour. If the car is electric, this price is halved to £2 per hour. Write an algorithm to:
• take as input the number of hours the user has parked and whether their car is electric or not
• calculate and output the total price
• repeat continually until the user enters 0 hours.

You must use either:
• OCR Exam Reference Language, or
• a high level programming language that you have studied.
[6]
Login to save your answers
/ 6
9. Three incomplete pseudocode algorithms are given with a description of the purpose of each algorithm. Write the missing arithmetic operator for each algorithm.
a) Outputting 12 to the power of 2
[1]
print(12 2)
/ 1
b) Working out if a number is odd or even
[1]
number = 53 if number 2 == 0 then print("Even number") else print("Odd number") endif
/ 1
c) Finding the difference between two measurements.
[1]
measurement1 = 300 measurement2 = 100 difference = measurement1 measurement2
/ 1
Please login to save your answers and marks.