6.4 Thinking Logically (OCR A Level Computer Science): Exam Questions

Exam code: H446

14 mins5 questions
12 marks

Define selection and provide an example of how it is used in a program

22 marks

Define the term 'iteration', and state how it is different from selection.

33 marks

Explain how logical conditions affect the flow of a program, and describe the role of Boolean operators in these conditions.

Provide an example.

44 marks

Describe the difference between a flowchart and pseudocode when designing algorithms, and give one advantage of each.

53 marks

The characters and prizes are designed as separate classes. 10 of the spaces on the road will contain an instance of the class Prize. The other spaces will be empty.

The class design for Prize is here

class: Prize

attributes:
private name : string
private type : string
private value : integer

methods:
new()
getName()
getType()
getValue()

new() is the constructor method. The name, type and value are passed to the constructor as parameters which then assigns these to the attributes.

The game starts with 10 prizes. Each prize is allocated to one space on the road.

An algorithm needs designing that will generate a random space on the road for each prize. Each road space can only store one prize.

Describe the decisions that will need to be made in this algorithm and how these will affect the program flow.