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

For C++ -- TrustUs Insurance has two divisions: 1) The life insurance division e

ID: 3736502 • Letter: F

Question

For C++ --

TrustUs Insurance has two divisions:
1) The life insurance division employing three sales persons that sell its life insurance policies to public in the Chicago, IL area.
2) The car insurance division employing two sales persons, selling car insurance policies to the public in the Chicago, IL area.

I. Create a class called Life that has the following member variables:

1) Int policy // number of life policies sold that month
2) double commission // commission paid to the employee
Class Life has a constructor that sets the value for member variable policy.
It has a public member function calcCommission that calculates and returns the value for commission per following scheme:


The function calcCommission also adds the value of commission to static variable totalcommission of class HeadOffice.
Class Life has a function called getCommission that returns the value of commission.

II. Create a second class called Auto that has the following member variables:
1) Int policy // number of auto policies sold that month
2) double commission // commission paid to the employee
Class Auto has a constructor that sets the value for member variable policy.
It has a public member function calcCommission that calculates and returns the value for commission per following scheme:


The function calcCommission also adds the value of commission paid to static variable totalcommission of class HeadOffice. Class Life has a function called getCommission that returns the value of commission.

III. Create third class called HeadOffice.

Class Headoffice has one static member variable totalcommission. Class headoffice has a static member function called getTotalCommission() that returns the value of total commission paid to all employees in both divisions.
Create the header file, specification files, and client file with the main() function.
In the client file:

1) Create an object each for each employee (arrays are fine) for both the divisions.
2) Calculate and display the total commission paid to all employees in both the divisions. Also display the individual commission earned by each employee in both divisions.

Note: The calcCommission() functions of Life and Auto classes must be made friends of the HeadOffice class.. Create Life and Auto classes above the HeadOffice class. Static member variables should be initialized outside the class.

Life Policies Sold That Month Commission Per Policy 0 0 1 to <10 500 per policy 10 to <20 500 each for first 9 policies and 1500 each for the remaining above and equal to 10 20 and above 500 each for first 9 policies, 1500 each for 10 – 19th policies and 2500 for each policy sold above and equal to 20

Explanation / Answer

#include <iostream>

using namespace std;

class Life

{

private:

int policy;

double commission;

public:

Life(){

policy=0;

commission=0.0;

}

void setPolicy(int p){

policy=p;

}

double calcCommission();

double getCommission(){

return commission;

}

};

class Auto{

private:

int policy;

double commission;

public:

Auto(){

policy=0;

commission=0.0;

}

void setPolicy(int p){

policy=p;

}

double calcCommission();

double getCommission(){

return commission;

}

};

class HeadOffice{

private:

static double totalCommission;

public:

static double getTotalCommission(){

return totalCommission;

}

friend double Life::calcCommission();

friend double Auto::calcCommission();

};

double HeadOffice::totalCommission;

double Auto::calcCommission(){

if(policy<10){

commission=500*policy;

}

else if(policy<20){

commission=(500*9)+(1500*(policy-9));

}

else{

commission=500*9+1500*10+(2500*(policy-19));

}

HeadOffice::totalCommission+=commission;

return commission;

}

  

double Life::calcCommission(){

  

if(policy<10){

commission=500*policy;

}

else if(policy<20){

commission=(500*9)+(1500*(policy-9));

}

else{

commission=500*9+1500*10+(2500*(policy-19));

}

HeadOffice::totalCommission+=commission;

return commission;

  

}

int main() {

int n; //total number of employees;

cout<<"Enter number of employees:";

cin>>n;

HeadOffice ho;

Auto autoo[n];

Life life[n];

for(int i=0;i<n;i++){

int policy;

cout<<"Enter auto insurance policies sold by employee "<<i+1<<": ";

cin>>policy;

autoo[i].setPolicy(policy);

autoo[i].calcCommission();

cout<<"Enter life insurance policies sold by employee "<<i+1<<": ";

cin>>policy;

life[i].setPolicy(policy);

life[i].calcCommission();

  

}

cout<<"Total Commission: "<<HeadOffice::getTotalCommission()<<endl;

cout<<"Commission of employees in Life insurence division:"<<endl;

for(int i=0;i<n;i++){

cout<<" Employee "<<i+1<<life[i].getCommission()<<endl;

}

cout<<"Commission of employees in Auto insurence division:"<<endl;

for(int i=0;i<n;i++){

cout<<" Employee "<<i+1<<autoo[i].getCommission()<<endl;

}

return 0;

}

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