A company of 20 employees wants to find the employee who made the highest commission so he/she can be paid a 10% bonus of the commission he/she earned for that month.
The commission an employee makes is calculated by multiplying the sales amount by the commission rate. The commission rates are shown below:
Sales Amount | Commission |
---|---|
Less Than 40000 | No commission |
40000 to 80000 inclusive | 5% |
Greater than 80000 | 10% |
Write a program to:
WRITTEN IN C++, ONLY IOSTREAM LIBRARY TO BE USED, NO ARRAYS TO BE USED
#include <iostream>
using namespace std;
int main()
{
int id,hId;
double sales,amount=0,commission=0,total=0,highestC=-1;;
for(int i=0;i<20;i++)
{
cout<<"Enter employee id of employee "<<(i+1)<<"
: ";
cin>>id;
cout<<"Enter sales amount of employee "<<(i+1)<<"
: ";
cin>>sales;
if(sales<40000)
{
commission=0;
}
else if(sales>=40000&&sales<=80000)
{
commission=0.05*sales;
}
else
{
commission=0.1*sales;
}
cout<<"Commission = "<<commission<<endl;
total=total+commission;
if(commission>highestC)
{
highestC=commission;
hId=id;
}
}
cout<<"Total commission earned by all employees =
"<<total<<endl;
cout<<"Average commission earned by an employee =
"<<(total/20.0)<<endl;
cout<<"Employee with the highest commission:\tEmployeeId =
"<<hId<<"\tCommission =
"<<highestC<<"\tBonus = "<<(0.01*highestC);
return 0;
}
Get Answers For Free
Most questions answered within 1 hours.