Homework Assignment 8

An Inventory Management Program

CS 1510
Introduction to Computing
Fall Semester 2014

Due: Monday, November 3, at 10:00 AM


For this assignment, you will write a new program from scratch. The focus is writing functions and practicing more with file I/O.

Spec 1: Inventory Management

Your client this week is a candy bar distributor that caters to the nostalgia market. This small company distributes just four products: Chunky, Skybar, Valomilk, and Zagnut. It needs a simple program to help it track its inventory of these vintage candy bars.

The program uses three text files:

  1. the initial inventory,
  2. the week's transactions, and
  3. the updated inventory.

Each inventory file consists of four lines, one per product. Each line contains a product name followed by the number of cases of that product in the warehouse. The name and number are separated by whitespace. The order of the four products in the file is not specified; neither is the case used for the candy bar name. For example, here are two possible input files:

    example one              example two
    ---------------          ---------------
    Chunky       12          ZAGNUT 8
    Zagnut        8          VALOMILK 3
    Skybar       19          SKYBAR 19
    Valomilk      3          CHUNKY 12

The transaction file lists all the transactions for the week, both sales to customers and purchases from candy manufacturers. Each line of this file consists of the data for a single transaction.

As with the inventory files, the data on each line are separated by whitespace, and the case used for the transaction types and candy bar names is unspecified. For example, here are a few possible transaction lines:

    sale chunky 1
    Sale      zagnut   8
    Purchase chunky 5

The program must take the following input from keyboard:

In addition to producing an output file that lists the week's closing inventory, the program must also print to the screen:

You may assume the following:

Here is some design and programming advice:

Name your program candybar_inventory.py.

Demonstration of Correctness

Start a fresh Python shell. Run the final version of your program on at least three sets of input files for beginning inventory and transactions. These input files should demonstrate that your program satisfies the program specification.

Save your shell to a text file named interactions.py.


By the due date and time, submit:

Use the on-line submission system.

Make sure that your program meets the course programming standards.

Eugene Wallingford ..... wallingf@cs.uni.edu ..... October 26, 2014