#K46747. Inventory Update
Inventory Update
Inventory Update
You are given an inventory of products and a series of sales transactions. Each product in the inventory is described by four fields: a unique ID (integer), a name (string), a price (floating-point number), and the number of units available (integer).
For each sale transaction, the program should check whether the requested quantity is available in the inventory. If it is, the product's available units should be reduced accordingly. Otherwise, the sale is not processed and a warning message is generated indicating that the sale could not be processed due to insufficient stock.
Process all transactions sequentially and then output the final state of the inventory along with any warning messages.
inputFormat
The input is given from standard input (stdin) in the following format:
- The first line contains an integer n, the number of inventory items.
- The next n lines each contain an inventory record with four values separated by spaces: ID (integer), name (string), price (float), and units (integer).
- The next line contains an integer m, the number of sales transactions.
- The following m lines each contain a sale transaction with two integers: ID and quantity.
outputFormat
The output should be written to standard output (stdout) in the following order:
- First, print a single line containing an integer representing the number of inventory items.
- Then, print n lines, each showing the updated inventory record in the format: ID name price units. The price should be displayed with two decimal places.
- Next, print a line with an integer representing the number of warning messages.
- Finally, if there are any warnings, print each warning message on a separate line.
If there are no warnings, output 0 in the warning count line.
## sample3
1 apple 0.50 500
2 banana 0.30 300
3 orange 0.70 700
2
1 200
3 800
3
1 apple 0.50 300
2 banana 0.30 300
3 orange 0.70 700
1
Cannot process sale of 800 units of item ID 3 since only 700 units are available.
</p>