Fuel cost of a trip
calc_fuel_costCalculates trip fuel needs and cost from distance, fuel price, and consumption; supports round trips, cost splitting, two-car comparison, and consumption unit conversion.
Instructions
Fuel needed and cost of a trip from distance (km or miles, optionally round trip), fuel price (per litre, US gallon or UK gallon) and consumption in L/100 km, km/L, mpg (US) or mpg (UK); split between people; cost per km/mile and per 100. Optionally compare a second car (its own consumption and, if different, fuel price). Also converts the consumption to the other units. Web version: https://s3eidat.github.io/fuel-cost/
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | Name of the car (default "Car A"). | |
| price | Yes | Fuel price per priceUnit. | |
| people | No | Split the cost between this many people. | |
| compare | No | Optional second car to compare. | |
| currency | No | Currency label for the text, e.g. "JD" or "$". | |
| distance | Yes | Trip distance (one way unless roundTrip). | |
| priceUnit | No | The price is per litre, US gallon or UK gallon. | L |
| roundTrip | No | Double the distance (there and back). | |
| consumption | Yes | Car consumption / economy, e.g. 7.5 (L/100 km) or 35 (mpg). | |
| distanceUnit | No | Distance unit. | km |
| consumptionUnit | No | l100 = L/100 km, kml = km/L, mpgus, mpguk. | l100 |