Test Informed Learning with Examples

Logo

Repository with assignments using the Test Informed Learning with Examples (TILE) method to integrate testing into existing programming courses for free.

Menu

LinkedIN Community

Join our LinkedIN Community.

Money breakdown in bills and coins

Read an amount of euros and display the minimum breakdown in bills and coins for that amount on the screen. This means that the minimum number of bills/coins must be returned. We assume that there are 500, 200, 100, 50, 20, 10 and 5 bills, and 2 and 1 coins.

Write a version of this program that shows the breakdown on the screen mentioning only the bills and coins we need.


>>> %Run 
    Enter an amount of euros: 434
    2 bills of 200
    1 bill of 20
    1 bill of 10
    2 coins of 2
>>> %Run 
    Enter an amount of euros: 0
    There are no bills or coins
>>> %Run 
    Enter an amount of euros: -35
    There are no bills or coins
>>> %Run 
    Enter an amount of euros: 1
    1 coin of 1
>>> %Run 
    Enter an amount of euros: 5
    1 bill of 5

What other tests could you run to ensure that your program has the desired behaviour? Have you tried, for example, entering different amounts that return all the bills and coins at least once? For example:

Have you tried, for example, entering different amounts to test whether your program returns the minimum number of correct combinations of bills and coins? For example:

Insisting that the students test their programs and think about all
possible combinations.