A cafe has a selection of menu items these are stored in an array called ITEMS, an example of which is shown below.
ITEMS = [ "Cake", "Sandwich", "Biscuit", ... , "Fried Rice", "Wedges", "Orange Juice"]
It also has an array called PRICES, which holds the price of each item, an example of which is shown below:
PRICES = [ 5500, 5000, 2000, ... , 6000, 2500, 3000]
The PRICES and ITEMS arrays are parallel arrays. Write some code that will write to a string array called MENU where each element of this array will hold the item followed by its price. Note, to align the information the price will be displayed in the 16th column, all prices are four digits long and the program doesn't need to check this. The variable MENU has already been created and is of the correct length. An example of the contents of this string is given below:
Cake 5500 Sandwich 5000 Biscuit 2000 ... Fried Rice 6000 Wedges 2500 Orange Juice 3000
When a customer places an order the system creates a 2 dimensional array called ORDER. This array records the index of the item that they have ordered and the quantity followed by any discount which is a percentage off. For example, an order of a cake, two biscuits and three orange juices with a 20% discount on the orange juice would appear as follows
ORDER = [ [ 0, 1, 0], [2, 2, 0], [12, 3, 20] ] // assume that Orange Juice has an index of 12
Construct the algorithm that will calculate the total bill. For example the above order would cost
Customers arrive at the cafe and place an order, their food will be prepared and then served to their table and after eating their food they will pay for their food. The customers ORDER is first placed in a Queue and once the ORDER has been completed the ORDER is added to the end of a Linked List called PAYMENTS.
Justify why a Queue is a good initial data structure
Justify why a Linked List is a better data structure than a Queue or Stack to hold the order after it has been served to the customer but before payment.
Suggest a reason for why the order is added to the end of the Linked List.
Suggest extra information that should be added to the order before inserting it onto the Linked List
Construct the algorithm that will take an ORDER from the Queue called ORDERS and insert at the end of the Linked List called PAYMENTS. The PAYMENTS Linked List uses a Node called PAYMENT_NODE which you may assume has been created but id empty. You may assume that the PAYMENTS Linked List is not empty.
Extended Response22 MarksShared
0 Uses1 View0 Likes
Login or Create an Account to view the mark scheme, comment, and add to a test