This algorithm calculates the delivery fee for a local organic farm's courier service based on distance and service level:
01 distance = input("Enter distance in km")
02 express = input("Is express delivery required? (Y/N)")
03 if distance >= 50.0 then
04 fee = 30
05 elseif distance >= 15.0 then
06 fee = 15
07 else
08 fee = 6
09 endif
10 if express == "Y" then
11 fee = fee + 10
12 endif
13 print("Delivery charge: £", fee)
Complete the trace table for the algorithm when a customer requests delivery for a distance of 18.5 and has express delivery input as "Y".
You may not need to use all the rows in the table.
| Line number | distance | express | fee | Output |
|---|---|---|---|---|
Practise OCR GCSE Computer Science Designing, creating and refining algorithms with exam-style questions for GCSE Computer Science. 50 questions, matched to the OCR GCSE Computer Science (J277) specification and written in Component 01 and Component 02 style. Every question includes a full worked solution and mark scheme, so you can see where marks are awarded rather than just whether you got the answer right.