CSSE 151 Fundamentals of Computer Science I

Programming Assignment #6

Program Due: Friday, June 6, 2008

You have been hired by a local electronics store, Everything Electronic!, to create a simple inventory program to track the various replacement parts they sell. You need information on the name of the item, the manufacturer, the quantity currently in inventory and the price of each item. The electronics store can stock up to 150 parts. You will offer the store two reports: one report will to print out the inventory information including the total value of the inventory on hand for all parts; the second report will list only those items whose current quantity is below their minimum quantity (in other words, those items are under stocked and need to be ordered).

In short, using functions, arrays, structs and files, write a C++ program to:

1.  Clear the screen.

2.  Briefly describe the program with a welcome message.

3.  Ask the user for an input file name.

4.  Input the information from the file and sort by item name.

5.  Offer the user a menu with the two report choices and an option to quit.

6.  Repeat the menu until the user wishes to quit.

Your output should appear on the screen and should be similar to the examples below. The array of structs you create can store only the information included in the file. You must compute all other information required at the time it is required. (This is the way a “real” database works – computable information is not stored – it is computed when required.)

Inventory Report

Item Manufacturer Quantity Cost each Total value

Capacitor Ohmite 70 $ 0.73 $ 51.10

Oscilloscope EBrand 2 $100.00 $200.00

Resistor Ohmite 100 $ 0.05 $ 5.00

Number of different items: 3

Total quantity: 172

Total value of all items: $256.10

Press enter to continue...

Reorder Report

Item Manufacturer Quantity Minimum Order Cost

Capacitor Ohmite 70 80 10 $ 7.30

Resistor Ohmite 100 250 150 $ 7.50

Number of different items to order: 2

Total number to order: 160

Total cost: $14.80

Press enter to continue...

Notes:

1.  You may assume the strings are no more than 20 characters in length. You may also assume that the total value will not be more than four digits before the decimal point. You should line up decimal points (and include a $) for all columns involving dollars. Other numbers should also line up as in the example (right justified). Note that the report titles are centered on the screen.

2.  Note that the “setw()” function will not work directly on variables of type string. You can either use character arrays OR use the “c_str()” method on the string for formatting.

3.  Use the provided file “p6input.dat” for your input information. The file is available in my class directory. The instructions for copying it are below as well as a description of the file structure.

4.  Clear the screen at the beginning of each report.

5.  Have a pause at the end of each report before you return to the menu.

To copy the file needed from my class directory:

From the prompt in the directory you want it copied to, type

cp /home/fac/sreeder/class/c151/p6input.dat .

The file contains records for electronic parts in the following format:

Item name / Manufacturer / Quantity / Mininum / Cost each
(string –single word) / (string – single word) / (integer) / (integer) / (double)

There is a single space between each piece of data. Each item is on a different line.

Extra Credit: Add the option to add to the inventory. The user must supply the item name and the additional quantity purchased. Your new option will locate the item (if it exists) and add the newly purchased quantity to the quantity already in stock. When the program ends, the database is written to an output file for the next use.