Supermarket Receipt

Write some code that could be used in a supermarket to calculate the total cost of items in a shopping cart and provide a receipt to the customer.

The supermarket has a catalog with different types of products (rice, apples, milk, toothbrushes,…). Each product has a price, and the total price of the shopping cart is the total of all the prices of the items. You get a receipt that details the items you’ve bought, the total price, and any discounts that were applied.

The supermarket runs special deals, e.g.

These are just examples: the actual special deals change each week.

Refactoring version

See also Supermarket Receipt Refactoring Kata


This exercise is loosely based on PragDave’s Kata01

Referenced in these Learning Hours: