#K49162. Inventory Management System
Inventory Management System
Inventory Management System
In this problem, you are required to implement an inventory management system that processes a series of operations. The system should support the following three types of operations:
add <item_id> <quantity>
: Add the specified quantity to the given item. If the item already exists, increase its stock.remove <item_id> <quantity>
: Remove the specified quantity from the given item. If the item does not exist, printItem not available
. If the removal quantity exceeds the current stock, printInsufficient stock
.check <item_id>
: Check and print the current stock for the given item. If the item is not found, printItem not found
.
The operations are applied in the order they are received. For every check
operation and error messages arising from remove
operations, output the corresponding message on a new line.
Note: All outputs should be printed to standard output.
inputFormat
The first line of input contains an integer n, denoting the number of operations.
Each of the following n lines contains a single operation, which can be one of the following formats:
add item_id quantity
remove item_id quantity
check item_id
outputFormat
For every check
operation as well as for error messages from remove
operations, print the corresponding output on a new line.
If the operation is check
and the item exists, output its current quantity. Otherwise, output the respective error message (Item not found
, Item not available
, or Insufficient stock
).
5
add 101 50
add 102 25
remove 101 30
check 101
check 103
20
Item not found
</p>