Problem G
Inventory Maintenance

Madam Phoenix (from Problem A) hasn't been too successful with her new numerology business, so she's moving to the southwest to open a "Fun In The Sun" store selling sunglasses, sunscreen, and other such items. Even though she didn't make a profit using your last program, she's decided to employ you again to write an inventory program for her new store. Here's how it will work.

Eachd "activity" your program is to process will appear as a separate line in the input file. Then end of the input is marked by a line containing an asterisk in column one; no other activity lines will be so marked. Activity lines begin with a lower-case keyword identifying he action to be performed. The names of the items in her inventory are case sensitive, and each contains no more than ten non-blank characters. All fields in the activity lines are separated by blanks, and Madam Phoenix guarantees you that there will be no errors in the input. Here are the various types of activity lines your program is to process.

new item-name item-cost item-selling-price
This line adds a new item (not previously carried in the store) to the potential inventory. The item-cost and item-selling-price are given as normal dollar amounts, without the dollar sign. That is, they will contain one or more decimal digits, a decimal point, and two more decimal digits. Note that this activity line doesn't actually result in a change n the inventory, but is used in anticipation of adding units of the new item to the store's offerings. item-cost is what Madam phoenix pays for each unit of the item, and item-selling-price is the price for which she sells the item. There will be no more than 100 total item-names ever included in the the list of items. item-cost and item-selling-price will never be larger than 100.00.
delete item-name
If an item isn't selling well, Madam Phoenix can remove it from the inventory by including this line in the program input. All units of item-name in the inventory are written off as a loss.
buy item-name quantity
When Madam Phoenix buys some units (at the unit-cost, previously indicated) of an item-name to offer for sale, she'll indicate that with one of these lines in the program input. quantity indicates the number of units she purchased. The quantity she purchases will never be larger than 5000 at a time, but the number of units in the inventory may be as large as 10,000.
sell item-name quantity
When one or more units of an item are sold, that fact is recorded by placing one of these lines in the input. quantity indicates the number of units sold (at the item-selling-price previously indicated). Obviously, the quantity sold cannot exceed the number of items in stock.
report
This line in the input requests a report. This is the only input line for which output is expected. Your program will display columns, with suitable headings, showing item-name, the buying price, the selling price, the number of units in the inventory, and the value of the units in the inventory (that is, the product of the number of units in the inventory and the buying price). The lines in the report should be sorted in alphabetical order on item name.. Following the last item the total value of all units in the inventory should be displayed. Then finally, a line should appear showing the total profit since the last report was issued. Profit is defined as total sales, less the cost of the items sold, less the cost of items written off (by the delete activity). The sample output shown illustrates the desired format for the report. All numbers in the report must naturally be exact.

Sample solution

Sample Input

new Shade01 0.50 3.79
new Towel01 1.47 6.98
new Shade02 0.63 4.29
new BluBlock 1.00 4.98
buy BluBlock 100
sell BluBlock 2
buy Towel01 500
buy Shade01 100
buy Shade02 100
sell Towel01 1
sell Towel01 1
sell BluBlock 2
report
delete Shade01
sell BluBlock 5
new Shade03 0.51 1.98
buy Shade03 250
sell Towel01 5
sell Shade03 4
sell Shade02 10
report
*

Expected Output

                  INVENTORY REPORT
Item Name     Buy At      Sell At      On Hand        Value
---------     ------      -------      -------        -----
BluBlock        1.00         4.98           96        96.00
Shade01         0.50         3.79          100        50.00
Shade02         0.63         4.29          100        63.00
Towel01         1.47         6.98          498       732.06
------------------------
Total value of inventory                             941.06
Profit since last report                              26.94

                  INVENTORY REPORT
Item Name     Buy At      Sell At      On Hand        Value
---------     ------      -------      -------        -----
BluBlock        1.00         4.98           91        91.00
Shade02         0.63         4.29           90        56.70
Shade03         0.51         1.98          246       125.46
Towel01         1.47         6.98          493       724.71
------------------------
Total value of inventory                             997.87
Profit since last report                              39.93

Judge's Input Data

new Shade01 0.50 3.79
new Towel01 1.47 6.98
new Shade02 0.63 4.29
new BluBlock 1.00 4.98
buy BluBlock 100
sell BluBlock 2
buy Towel01 500
buy Shade01 100
buy Shade02 150
buy Shade01 25
sell Towel01 1
sell Shade02 15
sell Towel01 1
sell BluBlock 2
sell Shade01 2
sell Towel01 20
report
delete Shade01
sell BluBlock 5
new Shade03 0.51 1.98
buy Shade03 250
sell Towel01 5
sell Shade03 4
sell Shade02 10
report
new Towel02 1.93 9.95
buy Towel02 100
sell Shade03 10
buy Shade03 20
buy Shade02 5
sell Towel01 3
sell Towel02 1
delete Towel02
report
*

Expected Output from Judged Runs

                  INVENTORY REPORT
Item Name     Buy At      Sell At      On Hand        Value
---------     ------      -------      -------        -----
BluBlock        1.00         4.98           96        96.00
Shade01         0.50         3.79          123        61.50
Shade02         0.63         4.29          135        85.05
Towel01         1.47         6.98          478       702.66
------------------------
Total value of inventory                             945.21
Profit since last report                             198.62

                  INVENTORY REPORT
Item Name     Buy At      Sell At      On Hand        Value
---------     ------      -------      -------        -----
BluBlock        1.00         4.98           91        91.00
Shade02         0.63         4.29          125        78.75
Shade03         0.51         1.98          246       125.46
Towel01         1.47         6.98          473       695.31
------------------------
Total value of inventory                             990.52
Profit since last report                              28.43

                  INVENTORY REPORT
Item Name     Buy At      Sell At      On Hand        Value
---------     ------      -------      -------        -----
BluBlock        1.00         4.98           91        91.00
Shade02         0.63         4.29          130        81.90
Shade03         0.51         1.98          256       130.56
Towel01         1.47         6.98          470       690.90
------------------------
Total value of inventory                             994.36
Profit since last report                            -151.82