#C1979. Inventory Management and Order Processing

    ID: 45243 Type: Default 1000ms 256MiB

Inventory Management and Order Processing

Inventory Management and Order Processing

This problem simulates a bookstore inventory system and customer order processing. The program first reads the inventory details of books. Each line of inventory input consists of the book's title, author, format, price, and quantity, separated by commas. The inventory input ends with a line containing End Inventory.

Then the program processes one or more customer orders. An order begins with a line CustomerOrder, followed by the customer's name and one or more lines with the order items in the format: title, format, and quantity, separated by commas. Each order ends with a line EndOrder.

For each order, the program calculates the total cost. The cost is calculated as the sum of (price × quantity) for each item. Additionally, if the total cost of Physical book items in the order exceeds 100, a discount of 10% (i.e. \(0.1 \times \text{physical total}\)) is applied to the physical items subtotal. Afterwards, the inventory is updated by subtracting the purchased quantity from the corresponding book's quantity. Finally, the program outputs the total cost for the order and the updated inventory.

inputFormat

The input is provided via standard input (stdin) as follows:

  1. Multiple lines representing the inventory entries. Each line will be in the format:
    title, author, format, price, quantity.
  2. A line containing exactly End Inventory marks the end of the inventory section.
  3. One or more customer orders. Each order starts with a line CustomerOrder, then the next line contains the customer name, followed by one or more lines with the order items in the format:
    title, format, quantity. The order section ends with a line EndOrder.

outputFormat

The output is printed to standard output (stdout). For each order processed, first print a line with the total cost in the following format:

Total cost for {customer_name}: ${total_cost}

Then, print the updated inventory in the following format:

Updated Inventory
{book1_title}, {book1_author}, {book1_format}, {book1_price}, {book1_quantity}
{book2_title}, {book2_author}, {book2_format}, {book2_price}, {book2_quantity}
...

Prices should be displayed as floating point numbers (if applicable) and quantities as integers.

## sample
Harry Potter, J.K. Rowling, Physical, 30, 50
Harry Potter, J.K. Rowling, E-Book, 15, 100
The Hobbit, J.R.R. Tolkien, Physical, 25, 20
The Hobbit, J.R.R. Tolkien, Audiobook, 20, 30
End Inventory
CustomerOrder
John Doe
Harry Potter, Physical, 3
The Hobbit, Physical, 2
EndOrder
Total cost for John Doe: $126.0

Updated Inventory Harry Potter, J.K. Rowling, Physical, 30.0, 47 Harry Potter, J.K. Rowling, E-Book, 15.0, 100 The Hobbit, J.R.R. Tolkien, Physical, 25.0, 18 The Hobbit, J.R.R. Tolkien, Audiobook, 20.0, 30

</p>