Question

In: Computer Science

It is common for an organization to have different categories of employees, such that one Employee...

It is common for an organization to have different categories of employees, such that one Employee class can not easily describe all types of Employees.In this project, you will code a basic Employee class, and then a number of classes which derive from the Employee class (inherit), adding Employee specifics. An application program which stores info for one company will have use objects of different types to model the all employees.

Part I:   The Employee Class

First create the Employee class described below. This class will serve as a base class. All specific employee typed will be derived from this class. :

Employee

-lastName:string

-firstName:string

-idNum:int

+Employee()    //default values assigned to all variables

+Employee(int idNum, string lname, string fname)

+void setLName(string)

+void setFName(string)

+void setIDNum(int)

+string getLName()

+string getFName()

+int getIDNum()

+void displayName()

+void display()

Stick with the access specifiers on the diagram. Items denoted as + are public, - are private.

NOTE: There are NO protected member variables in this class

The constructors both initialize all member variables. Sets functions set the indicated member variable of the object, and get functions return the value of the indicated member variable of the object.

The displayName() function prints out the last name and ID only, and the display()function outputs the all employee information that is stored.

PART II: The Derived Classes

Salaried

Hourly

Commission

-weeklySal:double

-payperhr:double

-hrsworked:double

-basesalary:double

-comAmount:double

+Salaried(string lname, string fname)

+Salaried(string lname, string fname, double sal)

+void setSal(double nsal)

+double getSal()

+void displaySal()

+void display()

+Hourly(string lname, string fname)

+Hourly(string lname, string fname, double newpay)

+void setPay(double)

+void setHrs(double nhr)

+double getPay()

+double getHrs()

+void displayHrly():

+void display()

+Commission(string  

        lname, string fname)

+Commission(string lname, string fname, double bsal)

+void setBase(double npay)

+void setCom(double nhr)

+double getBase()

+double getCom()

+void displayBase()

+void displayEmp()

As you can see, Employee is a base class, which is extended by the Hourly, Salaried and Commissioned classes. The derived classes describe 3 ‘types’ of employee.

Each of the derived classes provides instance data necessary for determining an employee’s weekly earnings, and both set (mutator) and get(accessor) methods for these additional variables. A salaried employee just gets a prearranged salary per week. An hourly employee’s weekly salary is based on the hourly rate and number of hours worked that week. A commissioned employee gets a base pay per week, plus the amount of commission earned that week. Each of these classes provides two display functions, one that outputs info specific for that class, one that overrides the base class function display(), to output all info on the object (both base and derived class data).

The displaySal() function outputs the employee name, id and weekly salary.

The displayHrly() function outputs the employee name, id and hourly rate.

The displayBase() function outputs the employee name, id and base pay.

Once these classes are working and tested you are ready to begin part III.

Part III The Application

You are to write an application which will allow the user to enter all his/her employees and their data. This application will allow the user to print out information on employees.

(This project will be updated in a future project assignment, so be sure to stick to the specifications. This will make the update happen more smoothly)

This application is to store each of the three types of objects in it’s own vector. That is, you will have a vector<Salaried>, a vector<Hourly> and a vector<Commission>.

Your program is to provide the following options for the user:

   * add a new salaried employee

   * add a new hourly employee

   * add a new commissioned employee

   * list all employees with a particular last name

   * output all information for all employees stored

   * search for an employee with a particular id number

   * output the name and salaries ONLY of all salaried employees

* output the name and hourly rate ONLY of all salaried employees

   * output the name, id and base salary of all commissioned employees

  

You are to submit 9 files, Employee.h, Employee.cpp, Salaried.h, Salaried.cpp, Hourly.h, Hourly.cpp, Commission.h, Commission.cpp, and your main program file.

Solutions

Expert Solution

PLEASE GIVE IT A THUMBS UP, I SERIOUSLY NEED ONE, IF YOU NEED ANY MODIFICATION THEN LET ME KNOW, I WILL DO IT FOR YOU

-----------------------------------
Employee.h
-----------------------------------
#ifndef Employee_H   
#define Employee_H

#include<string>

using namespace std;

class Employee
{

private:
   string lastName;
   string firstName;
   int idNum;

public:

   Employee(); //default values assigned to all variables

   Employee(int idNum, string lname, string fname);

   void setLName(string);

   void setFName(string);

   void setIDNum(int);

   string getLName();

   string getFName();

   int getIDNum();

   void displayName();

   void display();

};
#endif
-----------------------------------

-----------------------------------
Employee.cpp
-----------------------------------
#include<string>
#include<iostream>
#include"Employee.h"

using namespace std;

Employee::Employee() {
   //default values assigned to all variables
   lastName = "";
   firstName = "";
   idNum = 0;
}

Employee::Employee(int idNum, string lname, string fname) {
  
   this->lastName = lname;
   this->firstName = fname;
   this->idNum = idNum;
}
//Sets last name
void Employee::setLName(string lname) {
   this->lastName = lname;
}
//sets first name
void Employee::setFName(string fname) {
   this->firstName = fname;
}
//sets id num
void Employee::setIDNum(int idnum) {
   this->idNum = idnum;
}

//get last name
string Employee::getLName() {
   return lastName;
}
  
//get first name  
string Employee::getFName() {
   return firstName;
}

//get id num
int Employee::getIDNum() {
   return idNum;
}

//display id and last name
void Employee::displayName() {

   cout << endl << "ID Num : " << this->idNum;
   cout << endl << "Last name : " << this->lastName;
}

//display employee details
void Employee::display() {

   cout << endl << "ID Number " << this->idNum;
   cout << endl << "First name : " << this->firstName;
   cout << endl << "Last name : " << this->lastName;

}

-----------------------------------

-----------------------------------
Salaried.h
-----------------------------------
#ifndef Salaried_H   
#define Salaried_H

#include "Employee.h"
#include<string>

using namespace std;

class Salaried : public Employee{

private:

   double weeklySal;
public:

   Salaried();

   Salaried(int idNum, string lname, string fname);

   Salaried(int idNum, string lname, string fname, double sal);

   void setSal(double nsal);

   double getSal();

   void displaySal();

   void display();

};
#endif
-----------------------------------

-----------------------------------
Salaried.cpp
-----------------------------------
#include "Salaried.h"

#include<iostream>
using namespace std;

Salaried::Salaried():Employee() {
   this->weeklySal = 0;
}

Salaried::Salaried(int idNum, string lname, string fname) :Employee(idNum, lname, fname) {
   this->weeklySal = 0;
}

Salaried::Salaried(int idNum, string lname, string fname, double sal) : Employee(idNum, lname, fname) {
   this->weeklySal = sal;
}

//set salary
void Salaried::setSal(double nsal) {
   this->weeklySal = nsal;

}

//get salary
double Salaried::getSal() {
   return weeklySal;
}

//display name, id num, salary
void Salaried::displaySal() {

   cout << endl << "Name " << this->getLName();
   cout << endl << "ID Num " << this->getIDNum();
   cout << endl << "Weekly salary " << this->weeklySal;

   cout << endl << "------------------------------";

}

//Display employee details
void Salaried::display() {

   Employee::display();
   cout << endl << "Weekly salary " << this->weeklySal;
   cout << endl << "------------------------------";
}
-----------------------------------

-----------------------------------
Commission.h
-----------------------------------
#ifndef Commission_H   
#define Commission_H

#include<string>
#include "Employee.h"

using namespace std;

class Commission : public Employee{
private:

double basesalary;
double comAmount;

public:

Commission();

Commission(int idNum, string lname, string fname);

Commission(int idNum, string lname, string fname, double bsal);

void setBase(double npay);

void setCom(double nhr);

double getBase();

double getCom();

void displayBase();

void displayEmp();

};
#endif

-----------------------------------

-----------------------------------
Commission.cpp
-----------------------------------
#include "Commission.h"

#include <iostream>

using namespace std;

//sets Commission instance to default intial values
Commission::Commission():Employee() {

   this->basesalary = 0;
   this->comAmount = 0;
}

//Sets Commission instance to Commission parameters
Commission::Commission(int idNum, string lname, string fname):Employee(idNum, lname, fname) {
  
   this->basesalary = 0;
   this->comAmount = 0;
}

//Sets Commission instance to Employee plus Commision parameters
Commission::Commission(int idNum, string lname, string fname, double bsal):Employee(idNum, lname, fname) {
  
   this->comAmount = 0;
   this->basesalary = bsal;

}

//Sets base salary
void Commission::setBase(double npay) {
   this->basesalary = npay;
}

//Set commision salary
void Commission::setCom(double nhr) {
   this->comAmount = nhr;
}

//Get base salary
double Commission::getBase() {
   return basesalary;
}

//Get commission salary
double Commission::getCom() {
   return comAmount;
}

//Display base salary and commision salary
void Commission::displayBase() {

   cout << endl << "Name " << this->getLName();
   cout << endl << "ID Num " << this->getIDNum();
   cout << endl << "Base salary " << this->basesalary;

   cout << endl << "------------------------------";

}

//Display commission employee details
void Commission::displayEmp() {

   Employee::display();
   cout << endl << "Base salary " << this->basesalary;
   cout << endl << "Commission Amount : " << this->comAmount;

   cout << endl << "------------------------------";

}
-----------------------------------

-----------------------------------
Hourly.h
-----------------------------------
#ifndef Hourly_H   
#define Hourly_H

#include<string>
#include"Employee.h"

using namespace std;

class Hourly : public Employee{
private:

   double payperhr;
   double hrsworked;

public:

   Hourly();
   Hourly(int idNum, string lname, string fname);
   Hourly(int idNum, string lname, string fname, double newpay);
   void setPay(double);
   void setHrs(double nhr);
   double getPay();
   double getHrs();
   void displayHrly();
   void display();

};
#endif

-----------------------------------

-----------------------------------
Hourly.cpp
-----------------------------------
#include "Hourly.h"
#include <iostream>

using namespace std;


Hourly::Hourly():Employee() {

   this->payperhr = 0;
   this->hrsworked = 0;
}

Hourly::Hourly(int idNum, string lname, string fname):Employee(idNum, lname, fname) {

   this->payperhr = 0;
   this->hrsworked = 0;
}
Hourly::Hourly(int idNum, string lname, string fname, double newpay): Employee(idNum, lname, fname) {
  
   this->payperhr = newpay;
   this->hrsworked = 0;
}

void Hourly::setPay(double pphr) {
   this->payperhr = pphr;
}

void Hourly::setHrs(double nhr) {
   this->hrsworked = nhr;
}

double Hourly::getPay() {
   return payperhr;
}

double Hourly::getHrs() {
   return hrsworked;
}
void Hourly::displayHrly() {

   cout << endl << "Name " << this->getLName();
   cout << endl << "ID Num " << this->getIDNum();
   cout << endl << "Pay per hour " << this->payperhr;
   cout << endl << "------------------------------";
}
void Hourly::display() {
   Employee::display();
   cout << endl << "Pay per hour " << this->payperhr;
   cout << endl << "Hours worked : " << this->hrsworked;

   cout << endl << "------------------------------";
}
-----------------------------------

-----------------------------------
main.cpp
-----------------------------------
#include<iostream>
#include<vector>

#include "Salaried.h";
#include "Hourly.h";
#include "Commission.h";

using namespace std;

//Menu for all features
void menu();


//driver method
int main() {

   //store all salariedEmployees
   vector<Salaried> salariedEmployees;
   //store all hourlyEmployees
   vector<Hourly> hourlyEmployees;
   //store all commissionEmployees
   vector<Commission> commissionEmployees;

   //to store menu option
   int choice;

   //local variables for reading info
   double weeklySal;
string lastName;
string firstName;
   int idNum;
   double payperhr;
   double hrsworked;
   double basesalary;
   double comAmount;

   //Search employee id
   int searchIDNum;

   Salaried salariedEmp = Salaried();
   Hourly hourlyEmp = Hourly();
   Commission commissionEmp = Commission();

   do {
       //Dsiplay menu
       menu();

       //Ask user for menu option
       cout << endl << "Enter your choice :";

       //Read menu option
       cin >> choice;

       //Based on selected menu option, specific case will be executed
       switch (choice) {

       case 1:
           //add a new salaried employee
           cout << endl << "Enter salaried employee details :" << endl;
          
           cout << endl << "First name :"; cin >> firstName;
           cout << endl << "Last name :"; cin >> lastName;
           cout << endl << "ID Num :"; cin >> idNum;
           cout << endl << "Weekly Salary :"; cin >> weeklySal;

           salariedEmp.setFName(firstName);
           salariedEmp.setLName(lastName);
           salariedEmp.setIDNum(idNum);
           salariedEmp.setSal(weeklySal);

           salariedEmployees.push_back(salariedEmp);
           cout << endl << "salaried employee details added." << endl;

           break;

       case 2:
           //add a new hourly employee
           cout << endl << "Enter Hourly employee details :" << endl;

           cout << endl << "First name :"; cin >> firstName;
           cout << endl << "Last name :"; cin >> lastName;
           cout << endl << "ID Num :"; cin >> idNum;
           cout << endl << "Pay per Hour :"; cin >> payperhr;
           cout << endl << "Hours worked :"; cin >> hrsworked;

           hourlyEmp.setFName(firstName);
           hourlyEmp.setLName(lastName);
           hourlyEmp.setIDNum(idNum);
           hourlyEmp.setPay(payperhr);
           hourlyEmp.setHrs(hrsworked);

           hourlyEmployees.push_back(hourlyEmp);
           cout << endl << "Hourly employee details added." << endl;

           break;

       case 3:
           //add a new commissioned employee

           cout << endl << "Enter Commission employee details :" << endl;

           cout << endl << "First name :"; cin >> firstName;
           cout << endl << "Last name :"; cin >> lastName;
           cout << endl << "ID Num :"; cin >> idNum;
           cout << endl << "Base salary :"; cin >> basesalary;
           cout << endl << "Commission amount :"; cin >> comAmount;

           commissionEmp.setFName(firstName);
           commissionEmp.setLName(lastName);
           commissionEmp.setIDNum(idNum);
           commissionEmp.setBase(basesalary);
           commissionEmp.setCom(comAmount);

           commissionEmployees.push_back(commissionEmp);
           cout << endl << "Commission employee details added." << endl;

           break;

       case 4:
           //list all employees with a particular last name
           cout << endl << "Enter the last name (employees with mentioned last name's details will be displayed) : ";
           cin >> lastName;

           cout << endl << "Displaying employee who's has last name :" << lastName << endl;

           for (auto& it : hourlyEmployees) {

               if(it.getLName() == lastName)
                   it.display();
           }

           for (auto& it : salariedEmployees) {
               if (it.getLName() == lastName)
                   it.display();
           }

           for (auto& it : commissionEmployees) {
               if (it.getLName() == lastName)
                   it.display();
           }
           cout << endl << "Done displaying employee names";

           break;

       case 5:
           //output all information for all employees stored

           cout << endl << "Displaying all employee details "<< endl;

           for (auto& it : hourlyEmployees) {

                   it.display();
           }

           for (auto& it : salariedEmployees) {
                   it.display();
           }

           for (auto& it : commissionEmployees) {
                   it.display();
           }
           cout << endl << "Done displaying all employee details";

           break;

       case 6:
           //search for an employee with a particular id number
           cout << endl << "Enter the search IDNum : ";
           cin >> searchIDNum;

           cout << endl << "Displaying employee who's has ID Num :" << searchIDNum << endl;

           for (auto& it : hourlyEmployees) {

               if (it.getIDNum() == searchIDNum)
                   it.display();
           }

           for (auto& it : salariedEmployees) {
               if (it.getIDNum() == searchIDNum)
                   it.display();
           }

           for (auto& it : commissionEmployees) {
               if (it.getIDNum() == searchIDNum)
                   it.display();
           }
           cout << endl << "Done displaying employee details with mentioned ID num";

           break;

       case 7:
           //output the name and salaries ONLY of all salaried employees

           cout << endl << "Displaying name and salary of all salaried employees" << endl;

  
           for (auto& it : salariedEmployees) {
               cout << endl << "First Name : " << it.getFName();
               cout << endl << "Last Name : " << it.getLName();
               cout << endl << "Salary : " << it.getSal();
           }

           cout << endl << "Done displaying all salaried employee details";

           break;

       case 8:
           //output the name and hourly rate ONLY of all hourly employees

           cout << endl << "Displaying name and hourly rates of all hourly employees" << endl;


           for (auto& it : hourlyEmployees) {
               cout << endl << "First Name : " << it.getFName();
               cout << endl << "Last Name : " << it.getLName();
               cout << endl << "Hourly Rate : " << it.getPay();
           }

           cout << endl << "Done displaying all hourly employee details";

           break;

       case 9:
           //output the name, id and base salary of all commissioned employees
           cout << endl << "Displaying name , id and base salary of all commissioned employees" << endl;


           for (auto& it : commissionEmployees) {
               cout << endl << "First Name : " << it.getFName();
               cout << endl << "Last Name : " << it.getLName();
               cout << endl << "ID Num : " << it.getIDNum();
               cout << endl << "Base Salary : " << it.getBase();
           }

           cout << endl << "Done displaying all commission employee details";

           break;

       case 0:
           //exit
           cout << endl << "Exiting!";
           return 0;
           break;

       default:
           cout << endl << "Invalid choice, try again!";
       }

   } while (1);

   return 0;
}


void menu() {
  
   cout << endl << "---Employee database---" << endl;

   cout << endl << "1. add a new salaried employee";
   cout << endl << "2. add a new hourly employee";
   cout << endl << "3. add a new commissioned employee";
   cout << endl << "4. list all employees with a particular last name";
   cout << endl << "5. output all information for all employees stored";
   cout << endl << "6. search for an employee with a particular id number";
   cout << endl << "7. output the name and salaries ONLY of all salaried employees";
   cout << endl << "8. output the name and hourly rate ONLY of all hourly employees";
   cout << endl << "9. output the name, id and base salary of all commissioned employees";
   cout << endl << "0. Exit";
}

Related Solutions

C++ Requires 9 files It is common for an organization to have different categories of employees,...
C++ Requires 9 files It is common for an organization to have different categories of employees, such that one Employee class can not easily describe all types of Employees.In this project, you will code a basic Employee class, and then a number of classes which derive from the Employee class (inherit), adding Employee specifics. An application program which stores info for one company will have use objects of different types to model the all employees. Part I:   The Employee Class...
About the organization: This fictional organization has a small, but growing, employee base, with 50 employees...
About the organization: This fictional organization has a small, but growing, employee base, with 50 employees in one small office. The company is an online retailer of the world's finest artisanal, hand-crafted widgets. They've hired you on as a security consultant to help bring their operations into better shape. Organization requirements: As the security consultant, the company needs you to add security measures to the following systems: An external website permitting users to browse and purchase widgets An internal intranet...
Explore what impact the different auditor’s opinion will have on the audited organization, its employees and...
Explore what impact the different auditor’s opinion will have on the audited organization, its employees and its stakeholders. Do you feel it is absolutely necessary to audit an organization every year if they have continuously been issued a clean audit opinion? Why or why not?
Write a program in C to process weekly employee timecards for all employees of an organization...
Write a program in C to process weekly employee timecards for all employees of an organization (ask the user number of employees in the start of the program). Each employee will have three data items: an identification number, the hourly wage rate, and the number of hours worked during a given week.A tax amount of 3.625% of gross salary will be deducted. The program output should show the identification number and net pay. Display the total payroll and the average...
Write a program to process weekly employee time cards for all employees of an organization. Each...
Write a program to process weekly employee time cards for all employees of an organization. Each employee will have three data items: an identification number, the hourly wage rate, and the number of hours worked during a given week. Each employee is to be paid time and a half for all hours worked over 40. A tax amount of 3.625% of gross salary will be deducted. The program output should show the employee’s number and net pay. Display the total...
An important tactic for retaining employees is a good employee recognition program within the organization. Here...
An important tactic for retaining employees is a good employee recognition program within the organization. Here we what to examine how common they are in small (and large) businesses. With that in mind, you interview 376 of each kind. You find that 278 of the small organizations said they have an employee recognition program, while 316 of the large ones said they have an employee recognition program. We are trying to prove that larger organizations are more likely to have...
Problem Description An organization has a number of buildings and employees. Every employee has an office...
Problem Description An organization has a number of buildings and employees. Every employee has an office in one of the buildings. The application will store the employees, the buildings, and the relationships between employees and buildings. Entity interface The Entity interface represents an employee or a building. Every object of type Entity has a single method, with the following characteristics. • Name: getName() • Returns the name of the entity (a String object) • No parameters Employee class This class...
EMPLOYEE HEALTH AND SAFETY IN THE ORGANIZATION Organization officials have a legal and moral responsibility to...
EMPLOYEE HEALTH AND SAFETY IN THE ORGANIZATION Organization officials have a legal and moral responsibility to ensure that the workplace is free from unnecessary hazards. Employers hold responsibility for understanding what is necessary to keep workers safe from harm. Conditions surrounding the workplace must be secure for employee’s physical and mental health. As many organizations have implemented wellness program, that focus on smoking cessation, weight control, stress management, early diagnosis of health problems, prevention and education about life-style related and...
            TOPIC:   EMPLOYEE HEALTH AND SAFETY IN THE ORGANIZATION Organization officials have a legal and moral...
            TOPIC:   EMPLOYEE HEALTH AND SAFETY IN THE ORGANIZATION Organization officials have a legal and moral responsibility to ensure that the workplace is free from unnecessary hazards. Employers hold responsibility for understanding what is necessary to keep workers safe from harm. Conditions surrounding the workplace must be secure for employee’s physical and mental health. As many organizations have implemented wellness program, that focus on smoking cessation, weight control, stress management, early diagnosis of health problems, prevention and education about life-style...
Java Coding Part A Create a class Employee. Employees have a name.   Also give Employee a...
Java Coding Part A Create a class Employee. Employees have a name.   Also give Employee a method paycheck() which returns a double. For basic employees, paycheck is always 0 (they just get health insurance). Give the class a parameterized constructor that takes the name; Add a method reportDeposit. This method prints a report for the employee with the original amount of the paycheck, the amount taken out for taxes (we will do a flat 17%), and the final amount (for...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT