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

Write a program that displays the commission of a salesman using a function. Def

ID: 3627027 • Letter: W

Question

Write a program that displays the commission of a salesman using a function.
Define a function called CalcCommision.Your program should prompt the user to enter the sales amount in the Main module. Then the function CalcCommision is called by passing the sales to calculate the commission and return the value to the main module. The Main Module will display the sales and the commission.

Procedure or Details:
The following table is used to calculate the commission:

Sale Amount Commission
---------------- ---------------------------
0 – 999 3.5%
1000 – 1999 4.0%
2000 – 2999 4.5%
3000 or above 5.0%

******Your program will continue asking for the sales until the user types a negative number for sales, then the program should ask the user, if he/she wants to terminate the program. The program terminates if the user answers yes or y.

Explanation / Answer

please rate - thanks

#include <iostream>
#include <iomanip>
using namespace std;
double calcCommision(double);
int main()
{double sales,comm;
string yes;
bool stop=false;
cout<<"Enter the sales (negative to exit:) ";
cin>>sales;
while(!stop)
{
if(sales<0)
    {cout<<"Do you want to terminate(yes/no)? ";
    cin>>yes;
    if(yes.compare("yes")==0||yes.compare("y")==0)
         return 0;
    }
else
    cout<<"Sales: $"<<setprecision(2)<<fixed<<sales<<" commission $"<<
          calcCommision(sales)<<endl<<endl;
     cout<<"Enter the sales (negative to exit:) ";
     cin>>sales;
    
}

}   
double calcCommision(double sales)
{if(sales<1000)
       return .035*sales;
else if(sales<2000)
       return .04*sales;
else if(sales<3000)
       return .045*sales;  
else
       return .05*sales;   
}  

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