The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 6 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Hello,
I am trying to compile the lab for week 5 CIS247 DeVry, and it does not work. Please help!
Thanks!
Edwin Shankar
CIS247 WEEK 5
 
Â

Â
//Benefit.h
#pragma once
#ifndef BENEFIT_H
#define BENEFIT_H
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
Â
Â
class Benefit
{
private:
      string healthInsurance;
      double lifeInsurance;
      int vacation;
public:
      Benefit();
      Benefit(string, double, int);
      void displayBenefits();
      string getHealthInsurance();
      void setHealthInsurance(string);
      double getLifeInsurance();
      void setLifeInsurance(double);
      int getVacation();
      void setVacation(int);
};
#endif
Â
//Employee.h
#pragma once
#ifndef EMPLOYEE_H
#define EMPLOYEE_H
#include <iostream>
#include <string>
Â
#include "benefit.h"
#include <iomanip>
Â
Â
Â
class Employee
{
Â
public:
      Employee();
      Employee(string first, string last, char gen, int dep, double salary,Benefit);
      Employee(string first, string last, char gen, int dep, double salary,string healthIns, double lifeIns,int vacation);
      ~Employee();
      double calculatePay();
      void displayEmployee();
      string getFirstName();
      void setFirstName(string);
      string getLastName();
      void setLastName( string);
      char getGender();
      void setGender( char);
      int getDependents();
      void setDependents( int);
      double getAnnualSalary();
      void setAnnualSalary( double);
      static int getNumEmployees();
      void setDependents(string );
      void setAnnualSalary(string);
      //set benefit
      void setBenefit(Benefit);
Â
      // get benefit
      Benefit getBenefit();
     Â
Â
Â
      protected:
      string firstName;
      string lastName;
      char gender;
      int dependents;
      double annualSalary;
      Benefit benefit;
Â
   private:
      static int numEmployees;
     Â
};
#endif
Â
//Hourly.h
#pragma once
#ifndef HOULRLY_H
#define HOURLY_H
#include <iostream>
#include <string>
#include "benefit.h"
#include "employee.h"
#include <iomanip>
Â
Â
class Hourly : public Employee
{
      private:
      //declare data members
   static   const double MIN_WAGE;Â
      static const double MAX_WAGE ;
      static const double MIN_HOURS ;
      static const double MAX_HOURS ;
      double wage;
      double hours;
      double sal;
      string category;
     Â
     Â
Â
      public:
      Hourly();
      Hourly(double, double, string);
      Hourly(string fname, string lname, char gen, int dep,
             double wage, double hours, Benefit ben, string category);
      double calculatePay();
      void setAnnualSalary();
      void displayEmployee();
      double getWage();
      void setWage(double);
   double getHours();
      void setHours(double Hours);
      string getCategory();
      void setCategory(string);
     Â
};
Â
#endif
Â
//Salaried.h
#pragma once
#ifndef SALARIED_H
#define SALARIED_H
#include <iostream>
#include <string>
Â
#include "benefit.h"
#include "employee.h"
#include <iomanip>
Â
Â
class Salaried : public Employee
{
Â
      private:
      static const int MIN_MANAGEMENT_LEVEL;
      static const int MAX_MANAGEMENT_LEVEL;
   static const double BONUS_PERCENT;
      int managementLevel;
Â
      public:
      Salaried();
      Salaried(string, string, char, int ,double, Benefit, int);
      Salaried(double, int);
Â
      double calculatePay();
      void displayEmployee();
      int getManagementLevel();
     Â
      void setManagementLevel(int);
     Â
};
Â
Â
#endif
Â
//Benefit.cpp
#include "benefit.h"
#include <string>
using namespace std;
Â
Benefit::Benefit()
{
      healthInsurance = "Not Provided";
      lifeInsurance = 0.0;
      vacation = 14;
}
Â
Benefit::Benefit(string health, double life, int vac)
{
      healthInsurance = health;
      lifeInsurance = life;
      vacation = vac;
}
Â
Â
Â
void Benefit::displayBenefits()
{
            Â
             cout << "Benefit Information" << endl;
             cout << "_____________________________________________________________\n";
             cout << "Health Insurance:     \t " << healthInsurance << "\n";
             cout << "Life Insurance:       \t " << lifeInsurance << "\n";
             cout << "Vacation:             \t " << vacation << " days" << "\n";
            Â
Â
Â
}
Â
string Benefit::getHealthInsurance()
{
      return healthInsurance;
}
Â
Â
void Benefit::setHealthInsurance(string hins)
{
      healthInsurance = hins;
}
Â
double Benefit::getLifeInsurance()
{
      return lifeInsurance;
}
Â
void Benefit::setLifeInsurance(double lifeIns)
{
      lifeInsurance = lifeIns;
}
Â
int Benefit::getVacation()
{
      return vacation;
}
Â
void Benefit::setVacation(int vaca)
{
      vacation = vaca;
}
Â
Â
//Employee.cpp
#include "employee.h"
#include "benefit.h"
#include <string>
using namespace std;
Â
Employee::Employee() : benefit()
{
      string firstName= "not given" ;
      string lastName = "not given";
      char gender = 'U';
      int dependents = 0;
      double annualSalary = 20000;
      numEmployees++;
Â
}
Â
Employee::Employee(string first, string last, char gen, int dep, double salary,string healthIns, double lifeIns,int vacation) :benefit(healthIns,lifeIns,vacation)
{
      this->firstName = first;
      this->lastName = last;
      this->gender = gen;
      this->dependents = dep;
      this->annualSalary = salary;
Â
      numEmployees++;
}
Â
Employee::Employee(string first, string last, char gen, int dep, double salary, Benefit ben)
{
Â
      this->firstName = first;
      this->lastName = last;
      this->gender = gen;
      this->dependents = dep;
      this->annualSalary = salary;
      this->benefit = ben;
      numEmployees++;
Â
}
Â
Â
double Employee::calculatePay()
      {
             annualSalary = annualSalary / 52;
             return annualSalary;
      }
Â
Â
      void Employee::displayEmployee()
      {
            Â
            Â
             cout << "_____________________________________________________________\n";
             cout << "Name:         \t " << firstName << " " << lastName << "\n";
             cout << "Gender:       \t " << gender << "\n";
             cout << "Dependents:   \t " << dependents << "\n";
             cout << "Annual Salary: \t " << setprecision(2) << showpoint << fixed << annualSalary << "\n";
             cout << "Weekly Salary: \t " << setprecision(2) << showpoint << fixed << calculatePay() << "\n";
             cout << endl;
             this-> benefit.displayBenefits();
             cout << endl;
Â
Â
      }
Â
      string Employee::getFirstName()
      {
             return firstName;
      }
Â
      void Employee::setFirstName(string first)
      {
             firstName = first;
      }
Â
     Â
      string Employee::getLastName()
      {
            Â
             return lastName;
      }
Â
      void Employee::setLastName(string last)
      {
             lastName = last;
      }
Â
     Â
      char Employee::getGender()
      {
            Â
             return gender;
      }
Â
Â
Â
      void Employee::setGender(char gen)
      {
             gender = gen;
      }
Â
      int Employee::getDependents()
      {
            Â
             return dependents;
      }
      void Employee::setDependents(int dep)
      {
             dependents= dep;
      }
Â
      // overloaded setdependents method
      void Employee::setDependents(string dep )
      {
             int depR;
        depR = atoi(dep.c_str());
Â
        dependents = depR;
        Â
     Â
      }
      double Employee::getAnnualSalary()
      {
             return annualSalary;
      }
Â
      void Employee::setAnnualSalary(double salary)
      {
             annualSalary = salary;
      }
Â
       // overloaded annual salary method
      void Employee::setAnnualSalary(string anuSal)
      {
             double anSa;
        anSa = stod(anuSal);
Â
        annualSalary = anSa;
        Â
      }
     Â
      int Employee::getNumEmployees()
      {
             return numEmployees;
      }
      int Employee::numEmployees = 0;
Â
Â
      Benefit Employee::getBenefit()
      {
             return benefit;
      }
Â
      void Employee::setBenefit(Benefit benes)
      {
              benefit = benes;
      }
Â
Employee::~Employee()
{
}
Â
Â
//Hourly.cpp
#include <iostream>
#include <string>
#include "hourly.h"
#include "benefit.h"
#include "employee.h"
#include <iomanip>
using namespace std;
Â
Â
Hourly::Hourly()
{
      wage = 0.0;
      hours = 0.0;
      category = "X";
}
Â
Hourly::Hourly( double wage , double hours, string category) :wage(wage), hours(hours),category(category)
{
     Â
Â
}
     Â
Hourly::Hourly(string fname, string lname, char gen, int dep,
             double wage, double hours, Benefit ben, string category):Employee(fname, lname, gen, dep,sal , ben)
             {
             }
Â
            Â
double Hourly::calculatePay()
      {
             return wage * hours;
      }
Â
void Hourly::setAnnualSalary(   )
      {Â
            Â
             annualSalary = calculatePay() * 50;
            Â
      }
      void Hourly::displayEmployee()
      {
            Â
             setAnnualSalary( );
                    cout<<"____________________________________________________________\n";
             cout<<"Name: \t\t"<<firstName<<" "<<lastName<<"\n";
             cout<<"Gender:\t\t"<<gender<<"\n";
             cout<<"Dependents: \t"<<dependents<<"\n";
             cout<<"Annual Salary:\t"<<setprecision(2)<<showpoint<<fixed<<annualSalary<<"\n";
             cout<<"Weekly Salary:\t"<<calculatePay()<<"\n";
              cout<<"Hourly Employee\n";
             cout<<"Category:\t"<<category<<"\n";
             cout<<"Wage:\t\t" <<setprecision(2)<<showpoint<<fixed << getWage() << "\n";
             cout<<"Hours:\t\t" <<setprecision(2)<<showpoint<<fixed << hours << "\n";
             this->benefit.displayBenefits();
      }
      double Hourly::getWage()
      {
             return wage;
     Â
      }
      void Hourly::setWage(double Wage)
      {
             wage=Wage;
      }
      double Hourly::getHours()
      {
             return hours;
      }
      void Hourly::setHours(double Hours)
      { Â
             if(Hours > MIN_HOURS || Hours < MAX_HOURS)
                    hours=Hours;
      }
      string Hourly::getCategory()
      {
             return category;
      }
      void Hourly::setCategory(string Category)
      {
      if (category=="temporary" || category=="part time" || category=="full time")
             category=Category;
      else
             Category = "Unknown";
         category=Category;
      }
Â
      // initialize static members here
            const double Hourly::MIN_WAGE  = 10;
         const double Hourly::MAX_WAGE  = 75;
         const double Hourly::MIN_HOURS = 0;
       const double Hourly::MAX_HOURS = 50;
Â
//Salaried.cpp
#include <iostream>
#include <string>
Â
#include "benefit.h"
#include "employee.h"
#include "salaried.h"
#include <iomanip>
Â
using namespace std;
Â
Salaried::Salaried():Employee()
{
      managementLevel = 0;
}
Â
Â
Salaried::Salaried(string fname, string lname, char gen, int dep,double sal, Benefit ben, int manLevel):
Employee(fname, lname,gen,dep,sal,ben)
{
  managementLevel = manLevel;
}
Â
Â
Salaried::Salaried(double sal , int manLevel):managementLevel(manLevel), Employee()
{
      Employee::setAnnualSalary(sal);
Â
}
Â
double Salaried::calculatePay()
{
      return Employee::calculatePay()*(1+(managementLevel*BONUS_PERCENT));
}
void Salaried::displayEmployee()
{
     Â
             cout<<"____________________________________________________________\n";
             cout<<"Name: \t\t"<<firstName<<" "<<lastName<<"\n";
             cout<<"Gender:\t\t"<<gender<<"\n";
             cout<<"Dependents: \t"<<dependents <<"\n";
             cout<<"Annual Salary:\t" << setprecision(2)<<showpoint<<fixed<<annualSalary<<"\n";
             cout<<"Weekly Salary:\t"<<calculatePay()<<"\n";
         cout<<"Salaried Employee\n";
             cout<<"Management Level:\t"<<managementLevel<<"\n";;
             this->benefit.displayBenefits();
Â
            Â
}
int Salaried::getManagementLevel()
{
      return managementLevel;
}
     Â
void Salaried::setManagementLevel( int manLevel)
{
      if ( manLevel >= MIN_MANAGEMENT_LEVEL || manLevel <=MAX_MANAGEMENT_LEVEL)
      {
             managementLevel =manLevel;
      }
      else
      {
              managementLevel = MIN_MANAGEMENT_LEVEL;
      }
}
     Â
   // initializing static variable of class
   const int Salaried::MIN_MANAGEMENT_LEVEL= 0;
      const int Salaried::MAX_MANAGEMENT_LEVEL= 3;
      const double Salaried::BONUS_PERCENT = .10;
Â
Â
     Â
//Program Header
//Program Name: Class Development
//Programmer: Student
//CIS247C, Week 5 Lab
//Program Description: Employee and benefit class creation with subclasses and input of employee data.
Â
//Main.cpp
#include <iostream>
#include "employee.h"
#include "benefit.h"
#include "hourly.h"
#include "salaried.h"
#include <string>
#include <stdlib.h>
#include <iomanip>
Â
using namespace std;
Â
Â
Â
void DisplayApplicationInformation();
Â
void DisplayDivider(string outputTitle);
Â
string GetInput(string inputType);
Â
void TerminateApplication();
Â
Â
Â
int main()
Â
{
     Â
Â
      Employee emply1;
     Â
     Â
     Â
      string firstNme;
      string lastNme;
      string input;
      char gend;
      int depen;
      double annualSalary;
      double lifeInsur;
      int vacat;
      string healthInsur;
      Benefit theBen;
     Â
Â
    DisplayApplicationInformation();
       DisplayDivider("Employee 1");
      firstNme = GetInput(" your First Name");
   emply1.setFirstName(firstNme);
Â
      lastNme = GetInput(" your Last Name");
   emply1.setLastName(lastNme);
     Â
       input = GetInput(" your Gender");
       gend = input.at(0);
       emply1.setGender(gend);
Â
     Â
      input = GetInput(" your Dependents");
      emply1.setDependents(input);
Â
      // prompt for annualsalary
      input = GetInput(" your Annual Salary");
   emply1.setAnnualSalary(input);
Â
      //prompt health insurance
      input = GetInput(" your Health Insurance");
Â
     Â
     Â
      theBen.setHealthInsurance(input);
     Â
Â
      //prompt life insurance
      input = GetInput(" your Life Insurance");
      lifeInsur = stod(input);
     Â
      theBen.setLifeInsurance(lifeInsur);
     Â
     Â
Â
      //prompt vacation
      input = GetInput( " your Vacation Days");
      vacat = atoi(input.c_str());
     Â
      theBen.setVacation(vacat);
Â
      emply1.setBenefit(theBen);
Â
      cout << "Employee Information" << endl;
     Â
     Â
   emply1.displayEmployee();
Â
      cout << "---- Number of Employee Object Created ---- "<< endl;
   cout << "Number of employees is : " << Employee::getNumEmployees() << endl;
Â
Â
     Â
Â
Â
      // create a salaried employee object
    Salaried salEmp;
Â
       DisplayDivider("Employee 2");
       firstNme = GetInput(" your First Name");
   salEmp.setFirstName(firstNme);
Â
      lastNme = GetInput(" your Last Name");
   salEmp.setLastName(lastNme);
     Â
       input = GetInput(" your Gender");
       gend = input.at(0);
       salEmp.setGender(gend);
Â
     Â
      input = GetInput(" your Dependents");
      salEmp.setDependents(input);
Â
     Â
      // prompt for annualsalary
      input = GetInput(" your Annual Salary");
   salEmp.setAnnualSalary(input);
Â
      //prompt health insurance
      input = GetInput(" your Health Insurance");
     Â
      theBen.setHealthInsurance(input);
     Â
      //prompt life insurance
      input = GetInput(" your Life Insurance");
      lifeInsur = stod(input);
Â
      theBen.setLifeInsurance(lifeInsur);
     Â
Â
      //prompt vacation
      input = GetInput( " your Vacation Days");
      vacat = atoi(input.c_str());
     Â
    theBen.setVacation(vacat);
     Â
       salEmp.setManagementLevel(3);
       salEmp.setBenefit(theBen);
      Â
     Â
Â
cout << "Employee Information" << endl;
     Â
     Â
   salEmp.displayEmployee();
Â
      cout << "---- Number of Employee Object Created ---- "<< endl;
   cout << "Number of employees is : " << Employee::getNumEmployees() << endl;
     Â
Â
Â
Â
Â
Â
      // create an hourly employee object
     Hourly hrEmp;
Â
       DisplayDivider("Employee 3");
       firstNme = GetInput(" your First Name");
    hrEmp.setFirstName(firstNme);
Â
      lastNme = GetInput(" your Last Name");
   hrEmp.setLastName(lastNme);
     Â
       input = GetInput(" your Gender");
       gend = input.at(0);
       hrEmp.setGender(gend);
Â
     Â
      input = GetInput(" your Dependents");
      hrEmp.setDependents(input);
Â
     Â
Â
     Â
Â
   //prompt health insurance
      input = GetInput(" your Health Insurance");
     Â
       theBen.setHealthInsurance(input);
     Â
Â
      //prompt life insurance
      input = GetInput(" your Life Insurance");
      lifeInsur = stod(input);
            Â
       theBen.setLifeInsurance(lifeInsur);
     Â
     Â
Â
      //prompt vacation
      input = GetInput( " your Vacation Days");
      vacat = atoi(input.c_str());
     Â
       theBen.setVacation(vacat);
     Â
       hrEmp.setAnnualSalary();
       hrEmp.setCategory("Unknown");
       hrEmp.setWage(40);
       hrEmp.setHours(50);
       hrEmp.setBenefit(theBen);
      Â
Â
cout << "Employee Information" << endl;
     Â
     Â
   hrEmp.displayEmployee();
Â
      cout << "---- Number of Employee Object Created ---- "<< endl;
   cout << "Number of employees is : " << Employee::getNumEmployees() << endl;
Â
     Â
Â
Â
   TerminateApplication();
Â
      system("pause");
Â
     Â
Â
 }
Â
Â
Â
 void DisplayApplicationInformation()
Â
 {
      Â
       cout << "Welcome the Employee Class Program " << endl;
Â
    cout << "CIS247C, Week 5 Lab" << endl;
Â
    cout << "Name: Edwin Shankar" << endl;
Â
    }
Â
Â
Â
 void DisplayDivider(string outputTitle)
Â
 {
Â
    cout << "********************"<< outputTitle << "************************"<< endl;
Â
 }
Â
Â
Â
 string GetInput(string inputType)
Â
 {
Â
  Â
Â
    cout << "Please enter"<< inputType <<" ";
Â
       getline(cin,inputType);
  Â
Â
    return inputType;
Â
 }
Â
Â
Â
 void TerminateApplication()
Â
 {
Â
    cout << "The end of CIS247C Week5 iLab" << endl;
Â
 }
Â
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly