Master C

Cost of the trip

Cost of the trip

A journey planner shows what a drive will cost in fuel. Cars quote their consumption in miles per gallon, filling stations sell fuel in litres, and the price on the sign is in pence, so three different units have to be brought together before anybody sees a number.

Write fuel_cost, returning the cost of the trip in pounds. Divide the miles by the miles per gallon to get gallons, multiply by 4.54609 to get litres, multiply by the price per litre to get pence, and divide by 100 to get pounds.

Worked example

Input:  miles = 120, mpg = 45, pence_per_litre = 149

120 / 45           = 2.6667 gallons
2.6667 * 4.54609   = 12.1229 litres
12.1229 * 149      = 1806.3 pence
1806.3 / 100       = 18.06 pounds

Output: 18.0631309333...

Constraints

  • miles is between 0 and 100000.
  • mpg is between 1 and 200, and may have a fractional part.
  • pence_per_litre is between 1 and 1000.
  • There are 4.54609 litres in an imperial gallon. Use that number.
  • Answers are accepted if they are close enough, since these are decimals rather than whole numbers. Do not round the result yourself.
Code

Run your code to see how it does on the examples. Submit also runs the hidden cases.