{
  "id": "change",
  "version": "547a8ba9f817",
  "status": "published",
  "name": "Change Calculator",
  "question": "How much change do I give back?",
  "summary": "Works out the change to give back from the amount due and the cash paid, and the fewest US bills and coins that make it up.",
  "category": "everyday-life",
  "subcategory": "money-and-shopping",
  "url": "https://www.acalculator.org/everyday-life/change-calculator",
  "markdown": "https://www.acalculator.org/everyday-life/change-calculator.md",
  "kind": "function",
  "method": "Change = cash paid − amount due, in whole cents; then, from the largest bill or coin down, give as many of each as fit in what is left.",
  "assumptions": [
    "Amounts are rounded to the nearest cent (half a cent rounds up) before the change is worked out.",
    "With the 5¢ option, the amount due is rounded the way the Treasury recommends for cash with no pennies: 1, 2, 6, 7 cents down, 3, 4, 8, 9 cents up, and a total of 1¢ or 2¢ up to 5¢. The cash paid is not rounded.",
    "Bills: $100, $50, $20, $10, $5, $1 (and $2 with the option on). Coins: quarter, dime, nickel, penny (and the half dollar with the option on). The $1 coin is left out.",
    "Taking the largest piece that fits each time gives the fewest pieces for US money."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "due": {
        "title": "Amount due",
        "description": "The total the customer owes.",
        "type": "number",
        "x-unit": "USD",
        "minimum": 0,
        "maximum": 1000000000
      },
      "paid": {
        "title": "Cash paid",
        "description": "The cash the customer hands over.",
        "type": "number",
        "x-unit": "USD",
        "minimum": 0,
        "maximum": 1000000000
      },
      "r5": {
        "title": "Round the amount due to 5¢",
        "description": "For cash with no pennies: an amount due ending in 1, 2, 6 or 7 cents rounds down to 5¢, and one ending in 3, 4, 8 or 9 cents rounds up.",
        "type": "boolean"
      },
      "rare": {
        "title": "Use $2 bills and half dollars",
        "description": "Also give change in $2 bills and 50¢ coins, which are legal tender but seldom used.",
        "type": "boolean"
      }
    }
  },
  "outputs": {
    "due": {
      "label": "Amount due in cash",
      "description": "The amount due to the cent, rounded to 5¢ when that option is on.",
      "format": "money"
    },
    "change": {
      "label": "Change due",
      "description": "Cash paid − amount due, in dollars and cents.",
      "format": "money"
    },
    "breakdown": {
      "label": "Bills and coins",
      "description": "The fewest bills and coins that add up to the change, largest first.",
      "format": "text"
    },
    "pieces": {
      "label": "Bills and coins in all",
      "description": "How many bills and coins the change takes.",
      "format": "integer"
    },
    "bills": {
      "label": "In bills",
      "description": "The part of the change given in bills.",
      "format": "money"
    },
    "coins": {
      "label": "In coins",
      "description": "The part of the change given in coins.",
      "format": "money"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "due": 13.37,
      "paid": 20,
      "r5": false,
      "rare": false
    },
    "outputs": {
      "due": 13.37,
      "change": 6.63,
      "breakdown": "1 × $5 bill, 1 × $1 bill, 2 × quarters, 1 × dime, 3 × pennies",
      "pieces": 8,
      "bills": 6,
      "coins": 0.63
    },
    "text": "Paying $20.00 for $13.37 gives $6.63 in change: 1 × $5 bill, 1 × $1 bill, 2 × quarters, 1 × dime, 3 × pennies."
  },
  "examples": [
    {
      "given": {
        "due": 13.37,
        "paid": 20,
        "r5": false,
        "rare": false
      },
      "expect": {
        "change": 6.63,
        "breakdown": "1 × $5 bill, 1 × $1 bill, 2 × quarters, 1 × dime, 3 × pennies",
        "pieces": 8,
        "bills": 6,
        "coins": 0.63
      },
      "source": "U.S. Mint, Circulating Coins (penny 1¢, nickel 5¢, dime 10¢, quarter 25¢, half dollar 50¢), https://www.usmint.gov/learn/coins-and-medals/circulating-coins, retrieved 2026-10-02; hand calculation in content.mdx: 20.00 − 13.37 = 6.63 = 5 + 1 + 0.50 + 0.10 + 0.03"
    },
    {
      "given": {
        "due": 47.08,
        "paid": 100,
        "r5": false,
        "rare": false
      },
      "expect": {
        "change": 52.92,
        "breakdown": "1 × $50 bill, 2 × $1 bills, 3 × quarters, 1 × dime, 1 × nickel, 2 × pennies",
        "pieces": 10
      },
      "source": "U.S. Currency Education Program, The Seven Denominations ($1, $2, $5, $10, $20, $50 and $100 notes), https://www.uscurrency.gov/denominations, retrieved 2026-10-02; hand calculation in content.mdx: 100 − 47.08 = 52.92"
    },
    {
      "given": {
        "due": 47.08,
        "paid": 100,
        "r5": false,
        "rare": true
      },
      "expect": {
        "breakdown": "1 × $50 bill, 1 × $2 bill, 1 × half dollar, 1 × quarter, 1 × dime, 1 × nickel, 2 × pennies",
        "pieces": 8
      },
      "source": "hand calculation in content.mdx: 52.92 = 50 + 2 + 0.50 + 0.25 + 0.10 + 0.05 + 0.02"
    },
    {
      "given": {
        "due": 5,
        "paid": 5,
        "r5": false,
        "rare": false
      },
      "expect": {
        "change": 0,
        "breakdown": "No change",
        "pieces": 0
      },
      "source": "hand calculation in content.mdx: exact payment, no change"
    },
    {
      "given": {
        "due": 0.1,
        "paid": 0.3,
        "r5": false,
        "rare": false
      },
      "expect": {
        "change": 0.2,
        "breakdown": "2 × dimes",
        "coins": 0.2
      },
      "source": "hand calculation in content.mdx: 30¢ − 10¢ = 20¢"
    },
    {
      "given": {
        "due": 13.37,
        "paid": 20,
        "r5": true,
        "rare": false
      },
      "expect": {
        "due": 13.35,
        "change": 6.65,
        "breakdown": "1 × $5 bill, 1 × $1 bill, 2 × quarters, 1 × dime, 1 × nickel"
      },
      "source": "U.S. Department of the Treasury, Penny Production Cessation FAQs (symmetric rounding to the nearest 5 cents), https://home.treasury.gov/news/featured-stories/penny-production-cessation-faqs, retrieved 2026-10-02; hand calculation in content.mdx: 13.37 ends in 7, so 13.35; 20 − 13.35 = 6.65"
    },
    {
      "given": {
        "due": 8.48,
        "paid": 10,
        "r5": true,
        "rare": false
      },
      "expect": {
        "due": 8.5,
        "change": 1.5
      },
      "source": "hand calculation in content.mdx: 8.48 ends in 8, so it rounds up to 8.50; 10 − 8.50 = 1.50"
    }
  ],
  "sources": [
    "U.S. Department of the Treasury, Penny Production Cessation FAQs (symmetric rounding to the nearest 5 cents for cash; totals of $0.01 or $0.02 may round up to $0.05), retrieved 2026-10-02. https://home.treasury.gov/news/featured-stories/penny-production-cessation-faqs",
    "U.S. Currency Education Program, The Seven Denominations ($1, $2, $5, $10, $20, $50 and $100 notes), retrieved 2026-10-02. https://www.uscurrency.gov/denominations",
    "United States Mint, Circulating Coins (penny, nickel, dime, quarter, half dollar), retrieved 2026-10-02. https://www.usmint.gov/learn/coins-and-medals/circulating-coins"
  ],
  "related": [
    "tip",
    "unit-price",
    "discount"
  ],
  "changelog": []
}
