Tiered pricing (capstone)
Real invoices are rarely one formula - they're two or three small rules
applied in a strict order, and the order is where the money goes wrong. This
capstone is one of those: a wholesale order with a tiered discount, then
tax on top.
The rules:
- The first $1,000 of an order is full price - no discount.
- Everything above $1,000 gets 12% off (so that part costs 88% of list).
- Tax of 8% applies to the whole discounted total.
The trap is rule 2: the discount applies only to the amount above the
threshold, not the whole order. (order - 1000) * 0.88 is the discounted
upper tier; the first 1000 rides along untouched. Then the tax multiplies
the sum - which means the whole discounted total needs parentheses around
it before * 1.08, or the tax only hits the last thing you typed.
The starter shows the shape for a $1,500 order. This lesson's order is
$1,850.
Your task: compute the final invoice for a $1,850 order: first $1,000 at
full price, the remaining $850 at 12% off, then 8% tax on the whole thing.
You'll practice:
- Translating stacked business rules into one expression
- Parenthesizing so each rule applies to exactly the right part