UMBC CS 201,Fall 03
UMBC CMSC 201 Fall '03 CSEE | 201 | 201 F'03 | lectures | news | help

CMSC 201
Programming Project Three

Road Trip

Out: Wednesday 10/22/03
Due: before Midnight, Tuesday 11/4/03

The design document for this project, design3.txt ,
is due: Before Midnight, Tuesday 10/28/03

The Objective

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

The Background

This past summer, my husband and I went on a road trip through the New England states to Acadia National Park in Maine, and then west through upstate New York to Niagra Falls. We returned home through New York state and central Pennsylvania. We really enjoyed our trip and since my husband has never really travelled much, we decided that this summer we will do an extensive road trip across the United States.

On our trip, we kept track of our gas purchases and mileages so that we could see how many miles per gallon our car was getting. We found that our gas mileage varied quite a bit depending upon whether we were logging highway miles or were in slow traffic situations. The price of a gallon of gas varied quite a bit too. The highest price paid was on the New Jersey Turnpike. No surprise there. We also kept track of the amount of cash we were spending. We used cash for food, admission to museums and other attractions, souveniers, and miscellaneous items. We charged all of our hotels bills and gas purchases.

For this project, I would like you to use the information from the old trip to estimate the cost of the new trip.

The Task

Your task is to read in the gas information from the gas.dat file, and the hotel information from the hotel.dat file and then use this information along with the amount of cash spent, $1,159.84, to calculate the following data: You will then read in the itinerary for the new trip from the newtrip.dat file. It contains information about each leg of the journey, which includes a city of origin and the destination, the number of days planned to stay at the destination and the number of miles from the origin to the destination of that particular leg.

Using the total number of miles for the entire trip, the miles per gallon that you've calculated from last summer's data and the current price of gasoline per gallon, you must calculate the total cost of the gasoline for the new trip. Using the average cost per night for accomodation that you've already found, and the number of nights planned for the new trip, you can calculate the cost of accomodations. Using the cash spent per day that you've found from last summer's trip, and the number of days expected for the new trip, you can calculate the total cash needed.

More details

The data files

The data files are gas.dat, hotels.dat, and newtrip.dat, which can be viewed from these links. 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 files 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/umbc.edu/users/s/b/sbogar1/pub/gas.dat .
cp /afs/umbc.edu/users/s/b/sbogar1/pub/hotels.dat .
cp /afs/umbc.edu/users/s/b/sbogar1/pub/newtrip.dat .

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.

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 several other .c and .h files. I'll leave the naming of them to you.

Submit as follows:

submit cs201 Proj3 proj3.c (followed by any other .c & .h files you have)

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.