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

2.3. Create the classes in the class diagram shown below. 20 . An Employee shoul

ID: 3906218 • Letter: 2

Question

2.3. Create the classes in the class diagram shown below. 20 . An Employee should have a first name, last name and identity number . In addition, a SalariedEmployee should have a weekly salary: . A CommEmployee should have a commission rate and gross sales .A BaseCommEmployee should have a base salary Each class should have appropriate constructors, set methods and get methods. Henceforth, write a Tester program that instantiates objects of each of the above classes and outputs all the information associated with each object (including the inherited information). Employee CommEmployee BaseCommEmployee

Explanation / Answer

#include <iostream>
using namespace std;
class Employee
{
private:
int id;
string fname, lname;
public:
Employee(){}
void get1()
{
cout<<" Enter Employee First Name: ";
cin>>fname;
cout<<" Enter Employee Last Name: ";
cin>>lname;
cout<<" Enter Employee Identity Number: ";
cin>>id;
}
void set1()
{
cout<<" Employee First Name: "<<fname;
cout<<" Employee Last Name: " <<lname;
cout<<" Employee Identity Number: " <<id;
}
};
class CommEmployee : public Employee
{
private:
double gsale, crate;
public:
CommEmployee(){}
void get2()
{
get1();
cout<<" Enter Employee Commision Rate: ";
cin>>crate;
cout<<" Enter Employee Gross Sale: ";
cin>>gsale;
}
void set2()
{
set1();
cout<<" Employee Commission Rate: " <<crate;
cout<<" Employee Gross Sale: " <<gsale;
}
};
class BasicCommEmployee : public CommEmployee
{
private:
double salary;
public:
BasicCommEmployee(){}
void get_basic()
{
get2();
cout<<" Enter Employee Base Salary: ";
cin>>salary;
}
void set_basic()
{
set2();
cout<<" Employee Base Salary: " <<salary;
}
};
int main()
{
BasicCommEmployee emp;
cout<<" Output";
emp.get_basic();
emp.set_basic();
return 0;
}
  
  
Output
Enter Employee First Name: John
Enter Employee Last Name: Smith
Enter Employee Identity Number:001
Enter Employee Commision Rate: 22
Enter Employee Gross Sale: 350
Enter Employee Base Salary: 6000
Employee First Name: John
Employee Last Name: Smith
Employee Identity Number: 1
Employee Commission Rate: 22
Employee Gross Sale: 350
Employee Base Salary: 6000