Answer to Question #162422 in Algorithms for Sid

Question #162422

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.



1
Expert's answer
2021-02-09T15:26:46-0500
miles = input("Enter the number of miles: ")
cost = 0.3 * miles      
if cost > 10 then        
   cost = cost - cost * 0.1 
endif
print(cost)  

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS