Shopping Cart

Programming Interview Medium 9 views
Back to Questions

Problem Description

You will receive q commands: ADD item price, REMOVE item, TOTAL. Create Cart class. TOTAL prints sum of prices of current items.

Input Format

First line q. Next q lines commands.

Output Format

Outputs for TOTAL.

Sample Test Case

Input:
7 ADD pen 10 ADD book 50 TOTAL REMOVE pen TOTAL REMOVE book TOTAL
Output:
60 50 0

Constraints

q

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next