Record spending (Expense Tracker)

An expense tracker. add <YYYY-MM-DD <amount <category <note… records an expense (amount like 12.5 or 1500, at most 2 decimals; category lower-cased) and prints added <date <amount with 2 decimals <category. total prints total <sum (<n entries). Bad numbers or dates print error: bad input; anything else error: unknown command.

Input: One command per line.

Output: One line per command.

Difficulty: Easy. Write your answer in the browser editor, run the examples, then submit it against hidden tests. Python and JavaScript are free; other languages are part of licode Club.

Hint

  • Store money as whole cents (an integer), never as a float: 0.1 + 0.2 is not 0.3.

More Expense Tracker practice