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 |
|---|---|---|---|---|
41 exam-style questions on OCR GCSE Computer Science Designing, creating and refining algorithms. Each one has a worked solution and a mark scheme showing where the marks go.