{
  "schemaVersion": 1,
  "slug": "pet-cost-calculator",
  "category": "pets",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "3131b0cec483bc8620084eaea6489b77a2190a4aeddfed7bf2662a564678e590",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/pet-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": "C_life = C_one + Y × C_yr; C_yr = 12 × (food + ins + groom) + vet; C_avg = C_life ÷ (12Y)",
    "vars": [
      [
        "C_life",
        "Lifetime cost"
      ],
      [
        "C_one",
        "One-off first-year cost"
      ],
      [
        "Y",
        "Years of ownership"
      ],
      [
        "C_yr",
        "Recurring annual cost"
      ],
      [
        "C_avg",
        "Monthly average"
      ]
    ],
    "note": "If foodMonthly = 0, use type/size preset; emergency vet costs excluded."
  },
  "externalEvidence": {
    "reviewedAt": "2026-10-12",
    "sources": [
      {
        "name": "AVMA — Preventive pet care and veterinary expenses",
        "url": "https://www.avma.org/resources-tools/pet-owners/petcare"
      }
    ],
    "referenceRole": "context",
    "implementationHash": "3131b0cec483bc8620084eaea6489b77a2190a4aeddfed7bf2662a564678e590",
    "basis": "C_life = C_one + Y × C_yr; C_yr = 12 × (food + ins + groom) + vet; C_avg = C_life ÷ (12Y)",
    "limitations": "The references provide context and limitations. They do not validate this page’s illustrative multipliers, lookup values or predictions."
  },
  "contract": {
    "compute": "const baseFood = petType === 'dog' ? (size === 'small' ? 40 : size === 'large' ? 90 : 60) : petType === 'cat' ? 40 : 25; const food = foodMonthly > 0 ? foodMonthly : baseFood; const annualAfter = food*12+vetYearly+insuranceMonthly*12+groomingMonthly*12; const firstYear = annualAfter+oneOff; return { firstYear, annualAfter, lifetime: firstYear+annualAfter*Math.max(0, lifespanYears-1), monthlyAverage: (firstYear+annualAfter*Math.max(0, lifespanYears-1))/(lifespanYears*12) };",
    "inputs": [
      {
        "name": "petType",
        "type": "select",
        "default": "dog",
        "options": [
          {
            "value": "dog"
          },
          {
            "value": "cat"
          },
          {
            "value": "rabbit"
          },
          {
            "value": "bird"
          },
          {
            "value": "fish"
          }
        ]
      },
      {
        "name": "size",
        "type": "select",
        "default": "medium",
        "options": [
          {
            "value": "small"
          },
          {
            "value": "medium"
          },
          {
            "value": "large"
          }
        ]
      },
      {
        "name": "foodMonthly",
        "type": "number",
        "default": 0,
        "min": 0,
        "max": 2000,
        "step": 5,
        "slider": true
      },
      {
        "name": "vetYearly",
        "type": "number",
        "default": 300,
        "min": 0,
        "max": 5000,
        "step": 25,
        "slider": true
      },
      {
        "name": "insuranceMonthly",
        "type": "number",
        "default": 45,
        "min": 0,
        "max": 500,
        "step": 5,
        "slider": true
      },
      {
        "name": "groomingMonthly",
        "type": "number",
        "default": 25,
        "min": 0,
        "max": 1000,
        "step": 5,
        "slider": true
      },
      {
        "name": "oneOff",
        "type": "number",
        "default": 500,
        "min": 0,
        "max": 20000,
        "step": 25,
        "slider": true
      },
      {
        "name": "lifespanYears",
        "type": "number",
        "default": 12,
        "min": 1,
        "max": 40,
        "step": 1,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "firstYear",
        "precision": 0,
        "unit": "$"
      },
      {
        "name": "annualAfter",
        "precision": 0,
        "unit": "$"
      },
      {
        "name": "lifetime",
        "precision": 0,
        "unit": "$"
      },
      {
        "name": "monthlyAverage",
        "precision": 0,
        "unit": "$"
      }
    ],
    "interpret": null
  }
}
