From Professor and profound Potter Pundit David Martin:
As a Harry Potter fan who teaches Computer Science, I envy my fellow academics in other disciplines – such as philosophy and psychology – who can easily find so many ways to incorporate the Harry Potter novels into their courses. However, I have found one small area I can use in my Computer Science One course. Here it is:
========= The Assignment =================================
In the Harry Potter novels, the money used in the magical world comes in three denominations: bronze Knuts, silver Sickles, and golden Galleons. 29 Knuts equal one Sickle, and 17 Sickles equal one Galleon.
(I suppose that Rowling is here acknowledging – or satirizing? – the older British system of currency that was used until the “decimalization” reform of the 1970s. Under that older system there were 12 pence to the shilling and 20 shillings to the pound. British school children had a whole additional topic to study in math class just learning how to handle calculations in that non-decimal system.)
Let us imagine that the Ministry of Magic finances itself, in part, with a 4.5% sales tax on all goods sold in Diagon Alley, the main shopping area in the magical world.
Here is the assignment: Write a program to calculate this tax and add it to the cost of the sale.
Your program should begin by asking for the amount of the sale (in Galleons, Sickles, and Knuts) and then print out the amount the sale, the amount of the sales tax, and the total to be paid.
Here are two sample executions: