Question: If your programmer number is odd, you are assigned Task A . Make the following 2 functions. Copy mailOrderA.h from my public directory into your

If your programmer number is odd, you are assigned Task A. Make the following 2
functions.
Copy mailOrderA.h from my public directory into your cs111 directory. Complete the 2 functions in that file.
1.Write a function called calcDiscount that will calculate a discount amount and return it. If price is 100.00 and month is
5(5% discount), this function should return 5.00.
If you are returning only one value, what technique should you use? return rather than pass by reference
/**********************************************************
pr is the total price of all the items the customer is buying.
mo is the month when the customer is placing an order.
This function calculates a discount amount as follows and returns it.
Month ordered Discount on total sale amount (before tax)
Jan May 5%
Jun Aug 10%
Sep Dec 15%
**********************************************************/
????? calcDiscount(double pr, int mo)//You may not change these parameters
{
//Complete this function in mailOrderA.h that you downloaded from my public directory.
}
Compile your .h file.
[smith001@empress cs111] g++ mailOrderA.h
If your .h compiles, test calcDiscount before you move onto the next function.
How? (dont add main() in the .h file) Make a test .cpp called testMailOrder.cpp and create a main function in
this .cpp file (just like you made testMyMath.cpp to test myMath.h). Call only calcDiscount in main and make sure
it returns the right value. You dont need to call the other functions when you test calcDiscount. Each function
should be able to run and test independently from the others.
Test calcDiscount function for each category (5,10 and 15% discount). Make sure the function returns the correct value.
You could use the following 3 sets of values.
1. Total price =100.55
Month =5 testing 5% discount
2. Total price =100.55
Month =6 testing 10% discount
3. Total price =100.55
Month =9 testing 15% discount
//testMailOrder.cpp
Include your header file
int main()
{
//How do you show what the function returns? You have to add a little more code.
calcDiscount(100.55,5); // change the month
return 0;
}
Compile your .cpp and run.
[smith001@empress cs111] g++ testMailOrder.cpp

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!