Due Date:
Midnight, Thursday April 17
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:
Part 1 - The Pseudocode (20 points)
First, write the pseudocode to solve the problem. Be sure that your pseudocode includes the greeting and output labels shown in the sample program run below. Type the pseudocode in to a file called p5pseudo.txt.
Part 2 - The C Code (60 points)
Next, write the corresponding C program. Call it proj5.c.
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:
You will need to copy the file proj5.dat into your directory. To do this, go to the directory where you would like to store proj5.dat. Then, use the following command to copy proj5.dat into the directory:
Other Notes
"%d%%"
"%.2f"
Using symbolic constants rather than "hard coding" for these values will help to make your program easier to change in the future.
Sample Program Run
Here is an example of what an input data file might look like:
Your program's output should follow this EXACT format. (The values will be different because the data file proj5.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 pseudocode (p5pseudo.txt) and source code (proj5.c) to Gaurav (jolly1@umbc.edu) as attachments. Make the Subject of the e-mail Project 5 so that Gaurav knows what it is. Do NOT send your executable file (a.out) or the input data file (proj5.dat).