#C2119. Inventory Management System
Inventory Management System
Inventory Management System
You are given the task to implement an inventory management system that supports basic operations. The system should be capable of storing items and processing operations to add, update, retrieve, and delete items. Each item is identified by a unique identifier and has an associated description and quantity.
The supported operations are in the following formats:
ADD id "description" quantity
: Add a new item. If the item already exists, output: \(\texttt{Item already exists.}\)UPDATE id quantity
: Update the quantity of an existing item. If the item does not exist, output: \(\texttt{Item not found.}\)GET id
: Retrieve (print) the current quantity of the item. If the item does not exist, output: \(\texttt{Item not found.}\)DELETE id
: Remove an item from the inventory. If the item does not exist, output: \(\texttt{Item not found.}\)END
: Terminates the input.
Note that every operation is provided as a line of input from standard input. Your program must process these operations and output results to standard output.
The internal processing should respect the constraints mentioned and use appropriate data structures. The description may contain spaces and is always enclosed in double quotes.
inputFormat
The input consists of multiple lines where each line represents an operation. The operations are of the following types:
ADD id "description" quantity
UPDATE id quantity
GET id
DELETE id
END
The command END
signals the end of input.
outputFormat
Output the result of the GET operations and any error messages from the ADD, UPDATE, or DELETE operations. Each output should be printed on its own line.
## sampleADD item1 "Red Apple" 100
ADD item2 "Green Apple" 150
GET item1
UPDATE item1 120
GET item1
DELETE item2
GET item2
DELETE item2
END
100
120
Item not found.
Item not found.
</p>