UMBC CS 201, Spring 06
Spring '06

CSEE | 201 | 201 S'06 | lectures | news | help

CMSC 201
Programming Project Three


Out: Friday 3/31/06
Due: before Midnight, Sunday 4/16/06

The design document for this project, design3.txt ,
is due: Before Midnight, Sunday 4/9/06

The Objective

This project will give you practice using good design techniques, separate compilation, pointers, structures, arrays of structures, string comparison, C file-handling functions, and dynamic memory allocation.

The Background

Trains are used by industry to transport both their raw materials and finished goods and by farmers to ship their crops and livestock to market. Freight rates are different for each type of item shipped and are generally given in cents per ton-mile. A rate of 52.5 cents per ton-mile means that it will cost 52 and 1/2 cents to ship 1 ton of that item a distance of one mile. Rates vary quite a bit due to the density of some items. For instance, the rate for shipping coal needs to be much less than the rate for shipping eggs.

For this project, you will be keeping track of the cars found in one train. For each of the cars, there is a car identification number, the cargo being carried, the origin and destination, the number of miles being travelled from the origin to the destination, the weight of the items in the car in pounds, and the cost of shipping that car full of product.

You will also need to keep some information about the entire train. You'll need to know the number of cars in the train, the total weight of everything being shipped and the total shipping cost associated with the cars in this train.

The Task

Your task is to read in information from the cars.dat file, find the shipping cost for each car, and the train totals mentioned above. You will then use this information to print out a train report. You will also draw an illustration of this train using ascii art, which is a crude picture comprised solely of ascii characters. See the sample output for an example.

More details

The data files

The data file is cars.dat, which can be viewed from this link. You should NOT view it and save it into a file or cut and paste it from the browser into a file. Either of these methods of obtaining the file may cause there to be extraneous characters in the file that your program will try to read and disrupt the input of your data. Instead you must copy the file from my directory into the directory that you'll be using to work on this project.

Go to that directory and then issue the following commands exactly :

cp /afs/ .

The space and the . (dot) at the end of each command are necessary and a part of the command.

Sample Output

Since the output file is large, instead of showing the output here, I am just providing a link to my output file, output

Although your output may look different than mine, you should print out the same information and of course the format of the train drawing must be extremely similar, if not identical, to mine.

What to Turn In

You must use separate compilation for this project and should have a file, called proj3.c, that contains only the function main(). You should also have train.c and train.h.

Submit as follows:

submit cs201 Proj3 proj3.c train.c train.h

The order in which the files are listed doesn't matter. However, you must make sure that all files necessary to compile your project are listed.