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

(C++ program) Design a class for a sales person that has the following members v

ID: 3725560 • Letter: #

Question

(C++ program)

Design a class for a sales person that has the following members variable:

--EID: To holds the sales person’s employment ID

--Firstname: To holds the sales person’s first name.

--Lastname: To holds the sales person’s last name.

--Date: To holds the sales person’s birth date

--TotalAnnualSales: To holds the sales person’s total sales in a year.

In addition, the class should have the following member functions.

--Constructor: The constructor should accept the sales person’s data as arguments and assign these values to the object’s member variables.

--Mutators: Appropriate mutator functions should be created to allow values to be set for each object’s data members.

--Accessors: Appropriate accessor functions should be created to allow values to be retrieved from an object’s data members.

--calculateCommission: This function should calculate and display the commission amount for a sales person based on his totalAnnualSales. See below

  

Demonstrate the class in a program that creates a sales person object, and then calls each of the functions in the class.

--With the sales person class design in question #1 above in hand, write a program

--To have an array of sales person objects. The program should read and store information for each sales person in each of the object. It should then call a class function, once for each object, to display the sales person’s ToalAnnualSales amount and commission amount.

--This program should use bubble sort to sort the array of sales person objects. It places sales person objects in ascending order by their first name.

--Demonstrate the binary search method in this program to search by first name.

Show your output and comments!

TotalAnnualSales Commission Percentage Under $10,000 No commission $10,000-$20,000 2% of TotalAnnualSales Greater than $20,000 4% of TotalAnnualSales

  

Explanation / Answer

#include<iostream>
using namespace std;

class salesperson
{
int eid,tsales;
char fname[10],lname[10],bdate[10];
double commision;
public:
salesperson();
void setvalues();
salesperson(int,int);
void display();
void commission();
};
salesperson::salesperson()
{
eid=0;tsales=0;
}
void salesperson::setvalues()
{
int id,sales;
cout<<" Enter persons id:";
cin>>id;
cout<<" Enter First name:";
cin>>fname;
cout<<" Enter last name:";
cin>>lname;
cout<<" Enter date of birth:";
cin>>bdate;
cout<<" Enter sales:";
cin>>sales;
  
salesperson(id,sales);
}
salesperson::salesperson(int id,int sales)
{
eid=id;
//fname=x[0];
//lname=y[0];
//bdate=date[0];
tsales=sales;
}
void salesperson::display()
{
cout<<" ID FNAME LNAME DATE OF BIRTH TOTALSALE";
cout<<" "<<eid<<" "<<fname<<" "<<lname<<" "<<bdate<<" "<<tsales;
}
void salesperson::commission()
{
if(tsales<10000)
cout<<" No commision for sales under $10,000";
else
if(tsales>=10000 && tsales<=20000)
{
commision=((tsales*2)/100);
cout<<" Commision for sales >10,000 and <20,000="<<commision;
}
else
{
commision=((tsales*4)/100);
cout<<" Commision for sales >20,000="<<commision;
}
}
int main()
{
salesperson s;
  
int ch;
do
{
cout<<" Menu";
cout<<" 1=Enter details of Sales Person";
cout<<" 2=Dispaly Details";
cout<<" 3=Calculate Commision";
cout<<" 4=Exit";
cout<<" Enter your choice:";
cin>>ch;
switch(ch)
{
case 1:
{
  
s.setvalues();
break;
}
case 2:
{
s.display();
break;
}
case 3:
{
s.commission();
break;
}
case 4:
{
cout<<" End of Program";
exit(0);
}

cout<<" Enter another choice:";
cin>>ch;
}
}while(ch!=4);
return 0;
}

Sample out put:

Menu

1=Enter details of Sales Person

2=Display Details

3=Calculate Commission

4=Exit

Enter your choice:

1

Enter persons id:2

Enter First name:Matin

Enter last name:Alex

Enter date of birth:12-1-1987

Enter sales:10,000

Menu

1=Enter details of Sales Person

2=Display Details

3=Calculate C0mmission

4=Exit

Enter another choice:2

ID            FNAME                 LNAME                 DATE OF BIRTH                  TOTAL SALES

2              Martin                  Alex                       12-1-1987                            10000

Menu

1=Enter details of Sales Person

2=Display Details

3=Calculate C0mmission

4=Exit

Enter another choice:

3

No Commision for sales<10000

1=Enter details of Sales Person

2=Display Details

3=Calculate C0mmission

4=Exit

Enter another choice:

4

End of program.