In: Computer Science
Write a program that contains 2 functions. Program will call a function named calc_commission that prompt the user to enter the sales amount and computes and prints with a description the commission paid to salesperson as follows: 10% for sales amount less than $2,000.00, 15% for sales amount less than $10,000.00 and 20% for sales amount less than $20,000.00, then function calc_commission calls another function name assign_base_salary() to ask the user to enter each of 5 salesperson’s base salary , add the salary and commission earned and return to main program to print with a description the total of commission plus base salary. NEED THIS IN C++
#include <iostream>
using namespace std;
void assign_base_salary(double comm,double* salary)
{
double temp;
for (int i = 1;i<=5;i++)
{
cout<<"Enter salary of salesperson #"<<i<<" : ";
cin >> temp;
salary[i] = temp + comm;
}
}
double* calc_commission()
{
cout<<"Enter sales amount : ";
double sales,comm;
cin>>sales;
if(sales<2000)
comm = 0.1*sales;
else if(sales<10000)
comm = 0.15*sales;
else if(sales<20000)
comm = 0.2*sales;
else
{
cout<<"Invalid amount";
exit(0);
}
cout<<"Commission for salesperson : "<<comm<<" $\n";
static double salary[5];
assign_base_salary(comm,salary);
return salary;
}
int main()
{
double *finalpay;
finalpay = calc_commission();
for (int i = 1;i<=5;i++)
{
cout<<"Final pay of salesperson #"<<i<<" : "<<*(finalpay+i)<<" $\n";
}
return 0;
}