#K33412. Bookstore Inventory Management

    ID: 25082 Type: Default 1000ms 256MiB

Bookstore Inventory Management

Bookstore Inventory Management

The Bookstore Inventory Management problem requires you to implement a system that manages the inventory of books in a bookstore. Your task is to support three operations: adding books to the inventory, selling books while ensuring enough stock, and checking the stock for a given book identified by its ISBN. The system should process commands from standard input and produce the expected outputs.

The operations are as follows:

  • ADD: Add a new book or update an existing book's count. The command format is: ADD ISBN Title Author Count.
  • SELL: Sell a number of copies of the book. If the requested copies exceed the current stock, print \(\text{Insufficient stock}\). Command format: SELL ISBN Count.
  • CHECK: Check the current stock for a book. If the book is not in inventory, output 0. Command format: CHECK ISBN.

inputFormat

The first line contains an integer (T), denoting the number of operations. Each of the next (T) lines contains a command in one of the following formats:

  1. ADD ISBN Title Author Count
  2. SELL ISBN Count
  3. CHECK ISBN

Note: ISBN, Title, and Author are strings without spaces, and Count is an integer.

outputFormat

For every CHECK command, print the current stock. For SELL operations, if the stock is insufficient, print "Insufficient stock". All outputs should be printed to standard output.## sample

5
ADD 978-3-16-148410-0 TheGreatGatsby Fitzgerald 10
SELL 978-3-16-148410-0 4
CHECK 978-3-16-148410-0
SELL 978-3-16-148410-0 15
CHECK 978-3-16-148410-0
6

Insufficient stock 6

</p>