The Evening

The stall is closed, and Emma sums up the day. Finish the program with the line Evening:, and below it, print the barn as it is after the orders, in the same form and order as in the morning, with its total. Then print the best customer: the one who paid the most for all their orders together, and how much that was.

Earned: 124 coins
Evening:
potatoes: 30 x 1 = 30 coins
pumpkins: 2 x 15 = 30 coins
carrots: 8 x 2 = 16 coins
Total: 76 coins
Best customer: Anna (60 coins)

The potatoes and the pumpkins are now worth 30 coins each, so the potatoes go first, as the alphabet says. And Hugo paid twice today, 40 coins in all, which isn't enough to beat Anna. The exercise also tries a day on which he buys more.

A tip: if the morning's report is a function, the evening's is just a call. For the best customer, remember how you counted things with a dictionary in the lesson on dictionaries: the same pattern adds up coins.

That's the whole project. Your program keeps the books of a farm stall: it stores the barn and the prices in dictionaries and the orders in a list of records, sorts with a comparison function, and adds up what each customer paid. In the next lesson, Strings, you'll learn to work with texts: cut them, search in them and line them up in columns. Then the orders could come as a text, just as the customers write them.

Instructions

Print Evening:, and below it the barn again, as it is after the orders.

Below, print the best customer.

Start programming for free

By signing up, you agree to the Terms of Service and Privacy Policy.

Or sign up with:

3/3