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

(IN C++) In a particular factory, a shift supervisor is a salaried employee who

ID: 3813651 • Letter: #

Question

(IN C++)

In a particular factory, a shift supervisor is a salaried employee who supervises a shift. In addition to a salary, the shift supervisor earns a yearly bonus when his or her shift meets production goals. Design a ShiftSupervisor class that extends the Employee class. The ShiftSupervisor class should have a field that holds the annual salary and a field that holds the annual production bonus that a shift supervisor has earned. Write one or more constructors and the appropriate accessor and mutator methods for the class. Demonstrate the class by writing a program that uses a ShiftSupervisor object.

Here is the code for the Employee class it mentions

#include <string>
#include <iostream>
using namespace std;
class Employee
{
private: string empName;
       int empNum;
       string hireDate;
public:
   Employee() :empName(""), empNum(0), hireDate("") //default ctor
   {}
   Employee(string name, int num, string date)
   {
       empName = name;
       empNum = num;
       hireDate = date;
   }
   void setempName(string n);
   void setempNum(int nm);
   void setHiredate(string d);
   string getName();
   int getNum();
   string getDate();
   void print();
};
void Employee::setempName(string n)
{
   empName = n;
}
void Employee::setempNum(int nm)
{
   nm = empNum;
}
void Employee::setHiredate(string d)
{
   d = hireDate;
}
string Employee::getName()
{
   return empName;
}
int Employee::getNum()
{
   return empNum;
}
string Employee::getDate()
{
   return hireDate;
}

Explanation / Answer

#include<iostream.h>
#include<conio.h>

class employee
{
   int emp_num;
   char emp_name[20];
   float emp_basic;
   float sal;
   float emp_da;
   float net_sal;
   float emp_it;

   public:

       void get_details();
       void find_net_sal();
       void show_emp_details();
};

void employee :: get_details()
{
   cout<<" Enter employee number: ";
   cin>>emp_num;
   cout<<" Enter employee name: ";
   cin>>emp_name;
   cout<<" Enter employee basic: ";
   cin>>emp_basic;
}

void employee :: find_net_sal()
{
   emp_da=0.52*emp_basic;
   emp_it=0.30*(emp_basic+emp_da);
   net_sal=(emp_basic+emp_da)-emp_it;
}

void employee :: show_emp_details()
{
   cout<<" Details of : "<<emp_name;
   cout<<" Employee number: "<<emp_num;
   cout<<" Basic salary : "<<emp_basic;
   cout<<" Employee DA : "<<emp_da;
   cout<<" Income Tax : "<<emp_it;
   cout<<" Net Salary : "<<net_sal;
}

int main()
{
   employee emp[10];
   int i,num;
   clrscr();

   cout<<" Enter number of employee details ";
   cin>>num;

   for(i=0;i<num;i++)
       emp[i].get_details();

   for(i=0;i<num;i++)
       emp[i].find_net_sal();

   for(i=0;i<num;i++)
       emp[i].show_emp_details();

   getch();
   return 0;
}