A store charges their customers based on the number of items that they buy. Jane bought four items and was charged $15 and Georg
e bought twelve items and was charged $39. Write a function to model the cost based on the number of items you buy. Then determine how much you bought if you were charged $33.
Jane was charged $15/4 = $3.75 per item and George was charged $39/12 = $3.25 per item, so in addition to the charge per item, there must be an extra charge for each purchase.
We note that George bought 12-4 = 8 more items than Jane and was charged $39 - $15 = $24 more, or $24/8 = $3 more for each additional item. So if we figure $3 per item, we can find out that extra charge.
Jane paid 4 * $3 = $12 for her 4 items, plus $3 to make her total $15. George paid 12 * $3 = $36 for his 12 items, plus $3 to make his total $39. So we can see that if x is the number of items, the store charges x times $3 plus an extra $3.
Using function notation, we write f(x) = 3x + 3 and then work out the charge for 22 items: f(22) = 3 * 22 + 3 = 66 + 3 = 69