Stock Stack I

Widget Inventory Stock Stack - Static Implementation

FOR THIS ASSIGNMENT, WORK WITH THE STACK INSIDE AN ARRAY. (Stock Stack 2.0 will use a linked implementation.)

The Widget Store receives shipments of widgets at various costs. The store's policy is to charge a 20% markup and to sell widgets received later before widgets that were received earlier. This is a LIFO (last-in-first-out) policy.

Write a program that keeps track of the widgets in inventory using a stack. It will read input records of two types. Sales records and receipt records. A sales record represents a sale of a quantity of widgets and consists of the following fields: an 's', date of sale, time of day (a.m. or p.m.), and quantity. A receipt record represents a receipt of a quantity of widgets at a particular cost, and consists of: an 'r', date, time of day (a.m. or p.m.), quantity, and cost per item.

When a receipt record is read, print a message, e.g.:

After a sales record is read, print a message stating the number sold and the price for each widget. For example, if 200 widgets wre sold and there were 50 widgets from a shipment with a cost of $1.25, 100 at $1.10, and 50 at $1.00, the following would print (remember the 20% markup):

If there are an insufficient number of widgets in stock to fill an order, sell as many as are available and then print (e.g.),

The above messages are only guidelines. As usual, you may be creative with your output design. Make up your own data. You may read it in from the standard input device or from an input data file. Use structs, classes, arrays as appropriate.

50 WIDGETS RECEIVED AT $1.50. - COST: $75.00

50 WIDGETS SOLD AT $1.50. - SALE: $75.00

100 WIDGETS SOLD AT $1.32. - SALE: $132.00

50 WIDGETS SOLD AT $1.20. - SALE: $60.00

TOTAL FOR THIS SALE: $267.00

43 WIDGETS NOT AVAILABLE FOR SALE.