An algorithm is written to take as input the number of miles travelled. The algorithm works out how much this will cost, with each mile costing £0.30 in petrol. If this is greater than £10.00 then it is reduced by 10%.
miles = input("Enter the number of miles)
cost = 0.3
if cost = 10 then
cost = cost * 0.1
endif
print(cost)
There are four errors in this algorithm. Identify each error and correct it.
miles = input("Enter the number of miles: ")
cost = 0.3 * miles
if cost > 10 then
cost = cost - cost * 0.1
endif
print(cost)
Comments
Leave a comment