In: Computer Science
This program must be done in JAVA.
Write a program to monitor the flow of an item into an out of a warehouse. The warehouse has numerous deliveries and shipments for this item (a widget) during the time period covered. A shipment out (an order) is billed at a profit of 50% over the cost of the widget. Unfortunately each incoming shipment may have a different cost associated with it. The accountants of the firm have instituted a last-in, first out system for filling orders. This means that the newest widget are the first ones sent out to satisfy an order. This method of inventory can be represented by a stack. The Push procedure will insert an incoming shipment while a Pop should be called for a shipment out. Each data record in the text file warehouse.txt will consist of one shipment per line with fields (separated by white space of) I or O (char) shipment coming IN or shipment going OUT # (integer) quantity of the shipment Cost (float) cost per widget of the shipment (Incoming only) Vendor (String) name of the company sending or receiving the shipment Write the necessary procedures to store the shipments received and to process the orders. The output for an order consists of the quantity and the total costs of the widget in the order. Each widget price is 50% higher than its cost. The widgets used to fill an order may come from multiple shipments with different costs. If there are not sufficient widgets in inventory, use all the remaining and bill accordingly. When the simulation terminates display the total amount owed to each of the suppliers (incoming), the number of widgets on hand and the total profit.
Sample Input:
I 20 34.00 Fred’s Supply Company
I 30 25.00 Jumbo Exports
O 40 Acme Industries
Output:
Orders: Shipment to Acme Industries 40 units for $1635.00
Summary: Suppliers Fred’s Supply Company $680.00
Jumbo Exports $750.00
There are 10 widgets in the warehouse.
Profit is $545.00