Programming Assignment

Soft Drink Inventory


This is the specification for a simple inventory program for a soft drink distributor. The distributor handles 4 brands: Coke, Pepsi, Jolt, and Sprite. The program needs to be able to read in the initial inventory, then update the inventory with all the weekly transactions, then display the final inventory.


1.1 The inventory on hand (number of cases - a positive integer) for each brand at the start of the week.

1.2 The transactions for the week (sales and purchases). Each transaction consists of a brand and an amount. The transactions are to be entered in chronological order, NOT grouped by brand.

1.2.1 The brand is a single character, the first letter of each brand name (C, P, J, or S).

1.2.2 Assume all amounts are in case units. A positive integer value for purchases and a negative integer value for sales.

1.3 A Sentinel transaction indicating end of data. This way the user doesn't need to know ahead of time how many transaction there are. The character 'Q' is the value.


2.1 Title and brief directions to user.

2.2 Prompt for starting inventory

2.3 Prompt for transactions

2.4 Final Inventory title and labels

2.5 Final inventory amounts

2.6 Total number of transactions processed.


3.1 Print title and directions

3.2 Print prompt for starting inventory

3.3 Obtain starting inventory amounts from user for each brand

3.4 Print prompt for transactions

3.5 Obtain all weekly transactions

3.5.1 Obtain each transaction brand and amount

3.5.2 Ending with sentinel value.

3.6 Update inventory with weekly transactions

3.7 (Optional) If a sale would reduce the inventory below zero, do not update the inventory, but instead display an error message like "Not enough stock on hand to fulfill that transaction."

3.8 Display the final inventory and number of transactions.


4.1 If a brand name is entered that is not valid, print a message and ignore the transaction.


Here is a suggested example of the user interface. Yours does not have to look exactly like this. (Note: bold faced type below is user input).

Soft Drink Inventory Processing

This program reads in the initial inventory, then updates the inventory with all the weekly transactions, then display the final inventory.

Starting Inventory


Enter the number of cases on hand for each of the following brands:

Coke : 120

Pepsi : 90

Jolt : 75

Sprite: 112



Enter brand (C, P, S, J) and then amount. The amount should be a negative integer for sales and a positive integer for purchases.

C 30

C 15

P -20

S 25

C -40

... (continue to end of data)


End of Data

Final Inventory


Coke : 120

Pepsi : 90

Jolt : 75

Sprite: 120

Total transactions processed was: 17