CSC 160 - Program #4

ICE 5000 - Inventory Controller and Evaluator

Assigned: Mon Feb 10, 2003 Program #4 is worth 75 points
Program due: Weds Feb 19, 2003  

Concepts

In this program you will use the following "new" concepts:

  • Functions!
  • Arrays!
  • A little more rigorous work with files

 


Description

Write a program, ICE 5000, that tracks the inventory of a store or warehouse.

A typical ICE 5000 session has three parts:

  1. Read an inventory file
  2. Change inventory and get inventory reports interactively
  3. Write a new, updated inventory file

Step 1. Reading inventory

Initially, ICE 5000 queries the user for an initial inventory file. Example:

###
#  ICE 5000
#  Inventory Control and Evaluation
###
Enter inventory file> test1.txt

The inventory file must be read and processed. The format of this file is:

  • The first line of the file will be the name of the store or warehouse for this inventory file. 
  • Subsequent lines in the file will 2 two values: items and the amount of each item, separated by a comma.

An example inventory file is given in the Notes section below.

Step 2. Changing inventory interactively

With an inventory list in place, the user can now use ICE 5000 to change the inventory listing: add inventory for an item, remove/decrease inventory for an item, or add a new item to the inventory list. ICE 5000 also offers reports on the status of inventory. There are two options: Full inventory listing or statistics.

Shunning cumbersome menus, ICE 5000 queries the user for direction at each step. These queries follow this structure:

Change Inventory
    Add <item_name> <increase_amt> - add to item inventory
    Remove <item_name> <decrease_amt> - reduce item inventory
    New <item_name> <initial_amt> - add an item to inventory list
Report
    Full listing
    Statistics
Quit

An example ICE 5000 session appears in the Notes section below.

Step 2 (continued). Reporting inventory interactively

There are two report types:

  • Full inventory listing: Lists all items in inventory and their amounts
  • Statistics: Lists the following statistics:
    • Max - The item with the largest count in inventory
    • Min - The item with the smallest count in inventory
    • Average - The average inventory count over all items
    • Warning - Report all items with a warning-level low or high count

Step 3. Writing inventory

When the user quits ICE5000, query the user on saving the updated inventory list to a new file. If yes, then save the inventory (in the same format as the initial inventory file) to a specified file.

 


Implementation

Your implementation of ICE 5000 must:

  • Keep track of inventory using two arrays: one for item names, the other for item counts. You should be able to handle a maximum of 100 inventory items.
  • Create a function for each user option, such as:
    • readInventory() - read the initial inventory from a file
    • addItems() - increases the inventory count for an item
    • removeItems() - decreases the inventory count for an item
    • addNewItem() - adds a new item to inventory
    • listInventory() - report full inventory listing
    • reportInventory - report inventory statistics
    • writeInventory() - writes the inventory to a file

    These are suggestions, not absolute requirements. Your program design must use functions to simplify your code and reduce redundancy. Your functions should provide a functional and consistent interface. Please do not use global variables in your program, except for constants.

  • Use <iomanip> functions to format report output, where applicable.
  • Use constant variables, where applicable.

Hints

See page 937 of our text on using getline() with files and specifying a delimiter, like a comma, found in our inventory files.

Page 275 of our text has an example of reading the contents of an input file until the "end of file" (eof) is reached. 

And finally, Sections 8.1-8.8 show most (all?) of what you need to know about using arrays in your program.

 


Grading

Your program will be graded on three areas: design, quality, and function

Design (20%)

Your design must include detailed pseudo-code describing how your program will function. Please use the Pseudo-Code Quick Reference as a guide.

Quality (20%)

Your code should be well-commented, properly indented and structured, and contain informative and consistent names.

Function (60%)

Your program must implement the ICE 5000 program features per the description above.

I will provide test files in the Common Area of the k: drive to exercise your program. You are required to add at least two inventory files, and accompanying README file, on your own to this test suite showcasing the performance of your program.

 


Notes

Sample session

Here's an example ICE 5000 session, user input is in bold:

Enter inventory file> test1.txt
Dentist's Dream Candy Store inventory read
 
[C]hange inventory, [R]eport or [Q]uit> c
Change: [A]dd items, [R]emove items, or [N]ew item> a
Enter item name> Gum
Enter quantity to add> 15
15 units of Gum added, total is now 25
 
[C]hange inventory, [R]eport or [Q]uit> c
Change: [A]dd items, [R]emove items, or [N]ew item> n
Enter new item name> Twix
Enter initial quantity> 17
New item Twix added with 17 units
 
[C]hange inventory, [R]eport or [Q]uit> r
Report: [F]ull listing or [S]tatistics> s
output your statistics report here
 
[C]hange inventory, [R]eport or [Q]uit> q
Quit: Save current inventory to a new file? y
Save: Enter inventory file name> test1_update.txt
Dentist's Dream Candy Store inventory saved
 

Test files

Here's an example inventory file for the "Dentist's Dream Candy Store". This file is test1.txt in the Common Area/prog04 folder:

Dentist's Dream Candy Store
Gum,10
Licorice,22
Skittles,10
Warheads,5
Good n Plenty,33
Mr. Goodbar,4
Gummi Bears,102

More test files are coming soon...

Addendum

A couple clarifications:

  1. The statistic report mentions low and high inventory level warnings. A low inventory level is less than 10 units. A high inventory level is greater than 100 units. Low and high inventory warning should be displayed any time a change to inventory crosses either of these thresholds.