{
  "schemaVersion": 1,
  "slug": "road-trip-cost-calculator",
  "category": "travel",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "00d98321ae2c575687fcad9f626022e1dc756fcd92ecb23396c0b3673bee94c2",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/road-trip-cost-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": "T = D × P ÷ M + N × L + (N + 1)F + Q + E",
    "vars": [
      [
        "D",
        "Total distance (mi)"
      ],
      [
        "M",
        "Fuel economy (mpg)"
      ],
      [
        "P",
        "Fuel price ($/gal)"
      ],
      [
        "N",
        "Nights away"
      ],
      [
        "L",
        "Lodging per night ($)"
      ],
      [
        "F",
        "Food per day, all travellers ($)"
      ]
    ],
    "note": "Fuel = miles ÷ mpg × USD/gallon; trip days = nights + 1. Food is the daily group total; per-person cost divides by traveller count. Other costs are included only when entered."
  },
  "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": "00d98321ae2c575687fcad9f626022e1dc756fcd92ecb23396c0b3673bee94c2",
    "basis": "T = D × P ÷ M + N × L + (N + 1)F + Q + E",
    "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 fuelCost = mpg > 0 ? distance/mpg*fuelPrice : 0; const days = nights+1; const lodgingCost = nights*lodgingPerNight; const foodCost = days*foodPerDay; const total = fuelCost+lodgingCost+foodCost+tollsTotal+activitiesTotal; return { fuelCost, lodgingCost, foodCost, total, perPerson: total/travellers, perDay: total/days };",
    "inputs": [
      {
        "name": "distance",
        "type": "number",
        "default": 1800,
        "min": 1,
        "max": 30000,
        "step": 10,
        "slider": true
      },
      {
        "name": "mpg",
        "type": "number",
        "default": 28,
        "min": 1,
        "max": 200,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "fuelPrice",
        "type": "number",
        "default": 3.5,
        "min": 0,
        "max": 30,
        "step": 0.01,
        "slider": true
      },
      {
        "name": "nights",
        "type": "number",
        "default": 5,
        "min": 0,
        "max": 365,
        "step": 1,
        "slider": true
      },
      {
        "name": "lodgingPerNight",
        "type": "number",
        "default": 120,
        "min": 0,
        "max": 5000,
        "step": 5,
        "slider": true
      },
      {
        "name": "foodPerDay",
        "type": "number",
        "default": 90,
        "min": 0,
        "max": 2000,
        "step": 5,
        "slider": true
      },
      {
        "name": "tollsTotal",
        "type": "number",
        "default": 60,
        "min": 0,
        "max": 5000,
        "step": 5,
        "slider": true
      },
      {
        "name": "activitiesTotal",
        "type": "number",
        "default": 200,
        "min": 0,
        "max": 20000,
        "step": 10,
        "slider": true
      },
      {
        "name": "travellers",
        "type": "number",
        "default": 2,
        "min": 1,
        "max": 12,
        "step": 1,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "total",
        "precision": 2,
        "unit": "USD"
      },
      {
        "name": "perPerson",
        "precision": 2,
        "unit": "USD"
      },
      {
        "name": "fuelCost",
        "precision": 2,
        "unit": "USD"
      },
      {
        "name": "lodgingCost",
        "precision": 2,
        "unit": "USD"
      },
      {
        "name": "foodCost",
        "precision": 2,
        "unit": "USD"
      },
      {
        "name": "perDay",
        "precision": 2,
        "unit": "USD"
      }
    ],
    "interpret": null
  }
}
