{
  "schemaVersion": 1,
  "slug": "road-trip-fuel-planner-calculator",
  "category": "automotive",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "0e7587424b9ce2d40caa197e7b3092bc58b3f8a57a641224b8423be921e6e9be",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/road-trip-fuel-planner-calculator.json",
    "src/engine.js"
  ],
  "runtimeSource": "/sources/engine.txt",
  "runtimeHash": "5c888d8898afbdee36267bb9977829e1e2ac568f6677c8ee87469c139864645c",
  "scope": "The compute function records implemented equations, constants, lookup tables and custom rules. Inputs record defaults and allowed values; outputs record precision and units. Defaults are examples, not recommendations. General background references are not evidence for this specific algorithm.",
  "publishedFormula": {
    "formula": "G = D ÷ M; R = K × M × (1 - r ÷ 100); s = max(0, ceil(D ÷ R) - 1)",
    "vars": [
      [
        "D",
        "Distance (mi)"
      ],
      [
        "M",
        "Fuel economy (mpg)"
      ],
      [
        "K",
        "Tank capacity (gal)"
      ],
      [
        "r",
        "Reserve kept in tank (%)"
      ],
      [
        "s",
        "Refuelling stops"
      ]
    ],
    "note": "Usable range = tank gallons × mpg × (1 − reserve%). Stops assume a full tank at departure and refilling to full; the initial fill is not counted."
  },
  "externalEvidence": {
    "reviewedAt": "2026-10-12",
    "sources": [
      {
        "name": "US DOE/EPA — Fuel economy calculations and trip cost inputs",
        "url": "https://www.fueleconomy.gov/feg/savemoney.shtml"
      }
    ],
    "referenceRole": "input",
    "implementationHash": "0e7587424b9ce2d40caa197e7b3092bc58b3f8a57a641224b8423be921e6e9be",
    "basis": "G = D ÷ M; R = K × M × (1 - r ÷ 100); s = max(0, ceil(D ÷ R) - 1)",
    "limitations": "Use the cited guidance and your own measurements, bills or product specifications to choose inputs. Sample defaults are not current local data."
  },
  "contract": {
    "compute": "const totalGallons = mpg > 0 ? distance/mpg : 0; const range = tankSize*mpg*(1-reserve/100); return { totalGallons, totalCost: totalGallons*fuelPrice, range, stops: range > 0 ? Math.max(0, Math.ceil(distance/range)-1) : 0, costPerMile: distance > 0 ? totalGallons*fuelPrice/distance : 0 };",
    "inputs": [
      {
        "name": "distance",
        "type": "number",
        "default": 1200,
        "min": 1,
        "max": 50000,
        "step": 10,
        "slider": true
      },
      {
        "name": "mpg",
        "type": "number",
        "default": 28,
        "min": 1,
        "max": 200,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "tankSize",
        "type": "number",
        "default": 15,
        "min": 1,
        "max": 200,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "reserve",
        "type": "number",
        "default": 15,
        "min": 0,
        "max": 50,
        "step": 1,
        "slider": true
      },
      {
        "name": "fuelPrice",
        "type": "number",
        "default": 3.5,
        "min": 0,
        "max": 30,
        "step": 0.01,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "totalGallons",
        "precision": 2,
        "unit": "gal"
      },
      {
        "name": "totalCost",
        "precision": 2,
        "unit": "USD"
      },
      {
        "name": "range",
        "precision": 0,
        "unit": "mi"
      },
      {
        "name": "stops",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "costPerMile",
        "precision": 3,
        "unit": "$"
      }
    ],
    "interpret": null
  }
}
