Objective
Create a Python program that manages a list of expenses using an enumeration for the categories and a dataclass for each expense.
Instructions
- Read an integer
nand thennlines with the formatconcept amount CATEGORY. The concept has no spaces, the amount has at most two decimals and the category must beFOOD,TRANSPORT,LEISUREorOTHER. - If the category is not valid, show
Line k: invalid category (X)(withkthe line number, starting at 1) and discard the expense. - Store amounts in cents (integers) to avoid rounding errors. Show four
CATEGORY: x.xxlines (FOOD, TRANSPORT, LEISURE, OTHER) with the total of each category with two decimals, and thenTotal: x.xx. - If there are valid expenses, show
Biggest expense: concept (x.xx)(the first one on a tie) andMost expensive category: CATEGORY(the first in the order above on a tie). If there are none, showNo expenses.
4
pan 2.50 FOOD
bus 1.20 TRANSPORT
cine 9.00 LEISURE
regalo 5.00 GIFT
Line 4: invalid category (GIFT)
FOOD: 2.50
TRANSPORT: 1.20
LEISURE: 9.00
OTHER: 0.00
Total: 12.70
Biggest expense: cine (9.00)
Most expensive category: LEISURE
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise