Questions & Tests for

Pearson Edexcel International GCSE
Computer Science [4CP0]

2017 - 2023

About N7

Use N7 to quickly find high-quality questions by syllabus criteria and question type to easily compose targeted tests complete with detailed mark schemes. You can even add your own questions to the mix and share them with your community.

Learn more
A busy cafe has decided to streamline their business by implementing a software assisted ordering system. The new system will record customer orders at the front counter whereupon they are automatically added to a queue of orders accessed by a barista working at the back of the cafe to fulfill orders uninterrupted.
State one reason why a queue would be better suited to holding coffee orders than a stack.
The new systems holds the price for each type of coffee in an array called ITEMS as follows:
+--------------+--------------+ | Espresso | 1.20 | | Latte | 2.50 | | Cappuccino | 3.70 | +--------------+--------------+
Coffee orders are held in a queue called ORDERS where each order is a single integer indicating the type of coffee to be made by their respective row index in ITEMS array.
Additionally, a 3x3 2D array called SALES is initially defined as follows:
+--------------+--------------+--------------+ | Espresso | 0 | 0 | | Latte | 0 | 0 | | Cappuccino | 0 | 0 | +--------------+--------------+--------------+
Given ITEMS, ORDERS and SALES, write pseudocode such that column one and column two contain the total number of orders and total income for each coffee type respectively.
For example, the following ORDERS queue:
+-------+-------+-------+-------+-------+ 1 0 1 2 0 +-------+-------+-------+-------+-------+
would result in the following SALES array:
+--------------+--------------+--------------+ | Espresso | 2 | 2.40 | | Latte | 2 | 5.00 | | Cappuccino | 1 | 3.70 | +--------------+--------------+--------------+
The method rowswap(ARR, ROWA, ROWB) acts on the array ARR provided to swap the row at index ROWA with the row at index ROWB.
Without using loops, write pseudocode to sort the rows of SALES from lowest to highest total income. The row for the coffee with the highest total income should be at row index 2.
Extended Response10 MarksCommunity
76 Uses219 Views2 Likes
N7 Education

Ready to dive in?Start for free today.