Question Constellation Sign up for free

AQA · GCSE · Computer Science · Higher

Comparing record prices in pseudo-code

Q09.3 3 marks
Book records
VariablebookNameauthorprice
[object Object][object Object][object Object][object Object]
[object Object][object Object][object Object][object Object]

Write an algorithm using pseudo-code to display the name of the most expensive book. Compare the price of B1 and B2; output the book name of the most expensive book; output Neither if the books are the same price. The algorithm should work for any values stored in B1 and B2.

Write your answer first. You can study the marking guidance whenever you need it.

Study the marking See what earns credit and compare it with a full-mark answer.

Marking points

  1. 1 Uses selection capable of handling the three comparison outcomes.
  2. 2 Compares the price fields with correct conditions.
  3. 3 Outputs the correct bookName field or Neither on every route.

Full-mark answer

IF B1.price > B2.price THEN OUTPUT B1.bookName ELSEIF B1.price < B2.price THEN OUTPUT B2.bookName ELSE OUTPUT "Neither" ENDIF

Why this answer loses marks

If the first price is greater, output its name; otherwise output the second name.

This sends equal prices down the second-record route instead of providing the required tie outcome.