#K88817. Loyalty Points Tracker
Loyalty Points Tracker
Loyalty Points Tracker
You are required to implement a loyalty points tracking system for a store. Each customer has a unique identifier and can make various purchases that add points to their cumulative score. Additionally, the system should be able to answer queries regarding the total points for any customer. If a queried customer does not exist in the system, the output should be 0.
Operations:
- ADD customer_id points: Add the specified number of points to the customer's total.
- QUERY customer_id: Retrieve the total points for the customer.
Constraints:
- 1 ≤ n ≤ 100, where n is the number of operations.
- 1 ≤ customer_id ≤ 100
- 1 ≤ points ≤ 1000
Note: The input will be read from standard input (stdin) and the output should be written to standard output (stdout). The operations appear one per line, starting with a line that contains an integer n representing the number of subsequent lines.
inputFormat
The first line contains an integer n representing the number of operations. The following n lines each contain an operation in one of the following formats:
ADD customer_id points
QUERY customer_id
outputFormat
For each QUERY
operation, output the total points for the given customer_id on a new line. If the customer has not been added before, output 0
.
7
ADD 1 100
ADD 2 200
QUERY 1
QUERY 2
QUERY 3
ADD 1 50
QUERY 1
100
200
0
150
</p>