Graeme Foster

Graeme Foster

Member since
@gfoster
(a).
A cafe has a selection of menu items these are stored in an array called ITEMS, an example of which is shown below.
[6]
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
(b).
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
[6]
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
5500×1+2000×2+(3000×3)×(10020)100=167005500 \times 1 + 2000 \times 2 + (3000 \times 3) \times {(100-20) \over 100} = 16700
(c).
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.
(i).
Justify why a Queue is a good initial data structure
[1]
(ii).
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.
[2]
(iii).
Suggest a reason for why the order is added to the end of the Linked List.
[1]
(iv).
Suggest extra information that should be added to the order before inserting it onto the Linked List
[1]
(v).
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.
[5]
Extended Response22 MarksShared
1 Use25 Views1 Like
Graeme Foster
Contrast alpha and beta testing
[2]
Short Answer2 MarksCommunity
25 Uses29 Views1 Like
Graeme Foster
Explain how the OSI model helps with abstraction.
[4]
Short Answer4 MarksCommunity
27 Uses57 Views2 Likes
Graeme Foster