Checkpoint

Checkpoint: The Lantern Shop

The Lantern Shop on Emberreach needs a new till. Customers buy small or large lanterns, plus some oil to fill them. The shopkeeper wants a program that works out every bill.

This checkpoint uses the whole chapter: parameters, return, and small helper functions that call each other.

Assignment

  1. lantern_price(size) returns 8 if size is "large", otherwise 5.
  2. order_total(size, count, oil) returns the price of count lanterns of that size, plus 2 coins for each litre of oil. It must call lantern_price.
  3. receipt(name, size, count, oil) returns (not prints) a string like "Ada pays 26 coins". It must use order_total.

For example, Ada buys 2 large lanterns and 5 litres of oil: 2 * 8 + 5 * 2 is 26.