Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is part two to the first part: Write one function that reads the input usin

ID: 3551893 • Letter: T

Question

This is part two to the first part:


Write one function that reads the input using alias parameters (reference parameters).

Write a second function that calculates the pay amount. If the salesperson owes money, the

return amount from the function is a negative number.

main( ) will call each of these functions and print the appropriate messages to the screen.

  

Above each function definition, create a flowerbox of documentation that has:

1) The name of the function

2) A Short description of the purpose of the function

3) A

Explanation / Answer

#include <iostream>


#define COMM1 0.05

#define COMM2 0.10

#define COMM3 0.12

#define COMM4 0.14

#define COMM5 0.16


using namespace std;


/** READ function

* DESCRIPTION: This functions is used to read the

* amount of sales for the month and advance taken last month

* INPUT PARAMETERS: sales and advance are reference parameters

* and get their values from the user. These values of sales

* and advance are reflected in the main function also

* OUTPUT: No output. Just used to read the values from user

**/

void read(double& sales, double& advance){

cout << "Enter your sales for the month : " << endl;

cin >> sales;

cout << "Enter the advance amount : " << endl;

cin >> advance;

}


/** CALCULATEPAY function

* DESCRIPTION: This functions is used to calculate the monthly pay

* INPUT PARAMETERS: sales and advance are input parameters which

* hold the values of monthly sales and last month's advance'

* OUTPUT: Monthly pay

**/

double calculatePay(double sales, double advance){

double commissionRate, pay;

if(sales < 10000) commissionRate = COMM1;

if(sales >= 10000 && sales < 15000) commissionRate = COMM2;

if(sales >= 15000 && sales < 18000) commissionRate = COMM3;

if(sales >= 18000 && sales < 21000) commissionRate = COMM4;

if(sales >= 21000) commissionRate = COMM5;

pay = sales*commissionRate - advance;

return pay;

}


int main()

{

double sales,advance,pay;

  

read(sales,advance);

  

pay = calculatePay(sales,advance);

  

if(pay < 0){

cout << "You owe : " << pay*(-1) << endl;

}

else{

cout << "Your monthly pay is: " << pay << endl;

}


return(0);

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote