UMBC CS 104
UMBC CMSC 104 CSEE | 104 | current 104

CMSC 104, Spring 2003

Project 7 - The Book Fair Revisited

Due Date:

Midnight, Thursday May 15

Note: No late projects will be accepted.

Point Value:

This assignment is worth 80 points.

Objectives:

Assignment:

Background

UMBC recently held a book fair. As an incentive to customers, they implemented the following discount scheme:

purchase < $50.00 , 5% discount $50.00 <= purchase < $75.00, 10% discount purchase >= $75.00, 15% discount The manager of the bookstore would like you to write a program to determine the following:

The C Code

A file called proj7.c will provided for you. This file contains the function main and the #define directives you will need. Your job is to add the code for the function prototypes and the function definitions. Note that other than the addition of the prototypes and function definitions, you may not alter the given code in any way!.

You will need to copy the file proj7.c into your directory. To do this, go to the directory where you would like to store proj7.c. Then, use the following command to copy proj7.c into the directory:

cp /afs/umbc.edu/users/s/m/smitchel/pub/CS104/proj7.c . Notice that the space and period at the end of the command are part of the command.

The Input Data File

A data file containing all purchase amounts to use as input to your program will be provided. The last value in the file is -1.0. This is the sentinel value that signals the program to stop reading purchase amounts.

To use the data file as input to your program, you will use Linux redirection. By using redirection, you can tell Linux to read data from a file rather than from the keyboard. The scanf statement that you use in your program will look exactly the same as it would if you were getting your input from the keyboard. But since you will be getting the values from a file instead of from a user typing at the keyboard, you will not need to prompt the user.

When you run your program, use the following command:

a.out < proj7.dat This is how Linux redirection is done. It is saying to run your program and to read the input from the file proj7.dat, rather than the keyboard.

You will need to copy the file proj7.dat into your directory. To do this, go to the directory where you would like to store proj7.dat. Then, use the following command to copy proj7.dat into the directory:

cp /afs/umbc.edu/users/s/m/smitchel/pub/CS104/proj7.dat . Notice that the space and period at the end of the command are part of the command.

Other Notes

Sample Program Run

Here is an example of what an input data file might look like:

12.50 75.00 8.95 50.00 15.25 82.36 -1.0 Here is the output that would result from using this sample data file:
Book Fair Results Number of 15% purchases was 2 Number of 10% purchases was 1 Number of 5% purchases was 3 Smallest purchase made was $8.95 Largest purchase made was $82.36 Total of all purchases before tax was $244.06 Total of all purchases after tax was $256.26

Your program's output should follow this EXACT format. (The values will be different because the data file proj7.dat is different.)

Coding Standards:

Note that you MUST adhere to the coding standards and indentation style given on the Projects home page. So read them carefully and immediately!

Project Submission:

Submit your project by e-mailing your source code (proj7.c) to Gaurav (jolly1@umbc.edu) as attachments. Make the Subject of the e-mail Project 7 so that Gaurav knows what it is. Do NOT send your executable file (a.out) or the input data file (proj7.dat).


Last Modified: Thursday, 01-May-2003 21:42:28 EDT

Thursday, 01-May-2003 21:42:28 EDT