Lab 3 - Performing Computation Using Functions
Due - October 4/5, 2004
In this lab, you will write a program that uses functions to
perform basic computation. Your task is to write a program that
will calculate the amount of money a user must pay for a purchase
after her employee discount is applied to the original
purchase price. Your program will prompt the user for the
original price and the percentage of her employee discount. Using
both pieces of information, your program will calculate the dollar
amount to be discounted and the new total. Finally, you will
display the results for the user. An example run of your program
might look like the following:
Enter amount of purchase: 17.89
Enter discount percentage: 15
Your total savings is: $2.68
The final total of your purchase is: $15.21
Your program must implement at least five functions. Function one
will prompt the user for the original purchase price and return
the result (as a double). Function two will prompt the user for
the discount percentage and return the result. Function three
will take as input the original purchase price and the discount
percentage and return the discount amount (2.68 in the example
above). Function four will take as input the original purchase
price and the discount amount and return the final total.
Function five will take as input the discount amount and the final
total and print both pieces of information for the user.
Start by writing the documentation for each of your functions.
For each function, you must specify the type and function of each
input parameter and the type and function of the output. Next,
write an algorithm for each function (including main). Finally,
write, compile, and test your code.
Part 1 - Due - Monday, September 27, 2004 - 8:35AM
Submit
a program design and series of test cases. Your design should
consist of the functions you plan to implement, the input and
output of each function, and an algorithm for each function
(including main) which describes its behavior. Your test cases
should describe a series of tests you plan to perform to ensure
that your program functions correctly. An example test case might
look as follows:
Test case 1
-----------
Purchase amount: 100.00
Discount Percentage: 20%
Expected Savings: 20.00
Expected Total: 80.00
Part 2 - Due - October 4/5, 2004 - Beginning of Lab
Submit your completed code.
- Make sure that each function is well documented. Your documentation should specify the type and role of each of the input paramaters and ouput.
- Make sure a lab assistant (Dianne or I) has seen your program run.
- Copy and paste the output of your program to the bottom of your program itself. Make sure the output is a comment. That means, put a /* before the output and a */ after the output.
Sami Rollins