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: | 338 Weeks Ago, 1 Day 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