Okay so my assignment is as follows:
Write a program to calculate a salespersons commission based upon their monthly sales volume and
years of service. The program should prompt the user for the salespersons name, monthly sales volume, and
years of service. The output should display each of the input values along with the commission rate and
calculation (commission = rate * sales). Use constants where appropriate, suitable data types, and format the
output in fields with 2 decimal precision. Use the rates from the following table when determining the
commission rate. The one exception with the commission calculation is for the owner’s son in-law, “Bob
Freeloader”. His commission rate is always 50% higher than the other employees for a given level of sales and
years of service.
And my code is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
#include<iostream>
#include<iomanip>
#include<cstring>
#include<string>
using namespace std;
int main()
{
// char name[80];
double sales;
int years;
double commissionRate=0;
double commission=0;
std::string name;
std::cout<<"Please enter the employee name: ";
std::getline(std::cin, name);
cout<<"Please enter the monthly sales volume: ";
cin>>sales;
cout<<"Please enter employees years of service: ";
cin>>years;
if(years<10)
{
if((name,"Bob Freeloader")==0 && sales<50000)
commissionRate=0.03;
else if((name,"Bob Freeloader")==0 && sales>=50000)
commissionRate=0.06;
else if((name,"Bob Freeloader")!=0 && sales<50000)
commissionRate=0.02;
else
commissionRate=0.04;
}
else
{
if((name,"Bob Freeloader")==0 && sales<50000)
commissionRate=0.12;
else if((name,"Bob Freeloader")==0 && sales>=50000)
commissionRate=0.18;
else if((name,"Bob Freeloader")!=0 && sales<50000)
commissionRate=0.08;
else
commissionRate=0.12;
}
cout<<endl;
cout<<left<<setw(20)<<"Employee :"<<right<<setw(10)<<name<<endl;
cout<<left<<setw(20)<<"Sales Volume :"<<right<<setw(10)<<sales<<endl;
cout<<left<<setw(20)<<"Service Years :"<<right<<setw(10)<<years<<endl;
cout<<left<<setw(20)<<"Commission Rate :"<<right<<setw(10)<<commissionRate<<endl;
commission=sales*commissionRate;
cout<<left<<setw(20)<<"Commission :"<<right<<setw(10)<<commission<<endl;
return 0;
}
|
Now, it runs fine and I can input and get outputs, but whether i put in the name Bob Freeloader or any other name, the output is the same except that Bob's commission rate is supposed to be 50% higher than everyone else's. I cannot figure out why it will not work the way I need it to. Thank you