Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Program Name: Employee info
- //Programmer: Trevor England
- //Date: 2/4/16
- //Program Description: Program inputs data from the user and then returns it using a class and has a static number to count number of employees
- #include <iostream>
- #include <string>
- #include <stdlib.h>
- #include <iomanip>
- using namespace std;
- void DisplayDivider(string);
- string GetInput(string);
- class Salaried
- {
- private:
- int MIN_MANAGEMENT_LEVEL;
- int MAX_MANAGEMENT_LEVEL;
- double BONUS_PERCENT;
- int managementLevel;
- public:
- Salaried(){MIN_MANAGEMENT_LEVEL = 0, MAX_MANAGEMENT_LEVEL = 3,BONUS_PERCENT = .1, managementLevel = 0;}
- Salaried(string first, string last, int ID, char gen, int dep, double sal,Benefit befit, int manLevel){managementLevel = manLevel;}
- Salaried(double sal, int manLevel){;}
- double calcPay(){return managementLevel * BONUS_PERCENT;}
- void displayEmployee();
- };
- void Salaried::displayEmployee()
- {
- cout << "Mgmt Level: " << managementLevel << endl;
- };
- class Hourly
- {
- private:
- double MIN_WAGE;
- double MAX_WAGE;
- double MIN_HOURS;
- double MAX_HOURS;
- double wage;
- double hours;
- string category;
- public:
- Hourly(){MIN_WAGE = 10, MAX_WAGE = 75, MIN_HOURS = 0, MAX_HOURS = 50, wage = 0, hours = 0, category = "u" ;}
- Hourly(double w, double h, string cat){wage = w, hours = h, category = cat ;}
- Hourly(string first, string last, int ID, char gen, int dep, double sal,Benefit befit, double h, double w, string cat){;}
- double calcPay(){return wage * hours;}
- void setAnnualSalary(){calPay()* 50;} // HERE
- void displayEmployee();
- };
- void Hourly::displayEmployee()
- {
- cout << "Hourly wage: " << wage << endl;
- cout << "Hours: " << hours << endl;
- cout << "Category: " << category << endl;
- };
- class Benefit
- {
- private:
- string healthinsurance;
- double lifeinsurance;
- int vacation;
- public:
- Benefit(){healthinsurance = " ", lifeinsurance = 0, vacation = 0;}
- Benefit(string health, double life, int v){healthinsurance = health, lifeinsurance = life, vacation = v;}
- void displayBenefits();
- string getHealthInsurance(){return healthinsurance;}
- void setHealthInsurance(string health){healthinsurance = health;}
- double getLifeInsurance(){return lifeinsurance;}
- void setLifeInsurance(double life){lifeinsurance = life;}
- int getVacation(){return vacation;}
- void setVacation(int v){vacation = v;}
- };
- void Benefit :: displayBenefits()
- {
- cout << "\nHealth Insurance: " << healthinsurance << endl;
- cout << "Life Insurance: " << fixed << setprecision(2) << lifeinsurance << endl;
- cout << "Vacation Time: " << vacation << " days" << endl;
- };
- class employee
- {
- protected:
- string firstName,lastName;
- int empID, dependents;
- char gender;
- double annualSalary;
- Benefit benefit;
- private:
- static int numEmployees;
- public:
- employee(){firstName =" " , lastName = " ", empID = 0, dependents = 0, gender = 'U', annualSalary = 0;}
- employee(string first, string last, int ID, char gen, int dep, double sal, Benefit bfit): firstName(first), lastName(last), empID(ID), dependents(dep), gender(gen), annualSalary(sal), benefit(bfit){};
- double calcPay(){return annualSalary / 52;}
- void displayEmployee();
- static int getNumEmployees(){return numEmployees;}
- string getFirstName(){return firstName;}
- void setFirstName(string first){firstName = first;}
- string getLastName(){return lastName;}
- void setLastName(string last){lastName = last;}
- int getEmpID(){return empID;}
- void setEmpID(int ID){empID = ID;}
- void setEmpID(string ID) { empID=atoi(ID.c_str()); }
- char getGender(){return gender;}
- void setGender(char gen){gender = gen;}
- void setGender(string gen){gender = gen[0];}
- int getDependents(){return dependents;}
- void setDependents(int dep){dependents = dep;}
- void setDependents(string dep){dependents = atoi(dep.c_str());}
- double getAnnualSalary(){return annualSalary;}
- void setAnnualSalary(double sal){annualSalary = sal;}
- void setAnnualSalary(string sal){annualSalary = atof(sal.c_str());}
- void setBenefit(Benefit bfit){benefit = bfit;}
- Benefit getBenefit(){return benefit;}
- };
- int employee::numEmployees = 0;
- void employee::displayEmployee()
- {
- cout <<"Name : " << firstName << " " << lastName << endl;
- cout <<"Employee ID: " << empID << endl;
- cout <<"Gender: " << gender << endl;
- cout <<"Dependent: " << dependents << endl;
- cout <<"Annual Salary: " << fixed << setprecision(2) << annualSalary << endl;
- cout <<"Weekly Salary: " << fixed << setprecision(2) << calcPay() << endl;
- numEmployees++;
- cout << endl << endl << " Benefit Information" << endl << endl;
- benefit.displayBenefits();
- }
- void main()
- {
- string input;
- DisplayDivider("Employee 1");
- cout << endl << endl ;
- employee employee1;
- Benefit benefit1;
- input = GetInput("first name: ");
- employee1.setFirstName(input);
- cout << endl;
- input = GetInput("last name: ");
- employee1.setLastName(input);
- cout << endl;
- input = GetInput("employee's ID number: ");
- employee1.setEmpID(input);
- cout << endl;
- input = GetInput("employee's gender as (M - Male, F - Female:");
- employee1.setGender(input);
- cout << endl;
- input = GetInput("number of dependents: ");
- employee1.setDependents(input);
- cout << endl;
- input = GetInput("annual salary: ");
- employee1.setAnnualSalary(input);
- cout << endl;
- input = GetInput("Health Insurance: ");
- benefit1.setHealthInsurance(input);
- cout << endl;
- input = GetInput("Life Insurance: ");
- benefit1.setLifeInsurance(atof(input.c_str()));
- cout << endl;
- input = GetInput("Vacation Days: ");
- benefit1.setVacation(atoi(input.c_str()));
- cout << endl;
- DisplayDivider("Employee Information");
- cout << endl;
- employee1.setBenefit(benefit1);
- employee1.displayEmployee();
- cout << endl;
- DisplayDivider("Benefit Information");
- cout << endl;
- cout <<"\n\nNumber of Employees: " << employee::getNumEmployees() << endl;
- DisplayDivider("Employee 2");
- cout << endl << endl;
- Benefit benefit2("Aetna", 25000, 15);
- employee emp2("Olga", "Ayala", 4059612, 'F', 2, 27000, benefit2);
- DisplayDivider("Employee Information");
- emp2.displayEmployee();
- cout << endl;
- cout <<"\n\nNumber of Employees: " << employee::getNumEmployees() << endl;
- system("PAUSE");
- }
- void DisplayDivider(string title)
- {
- cout <<"**************** "<< title << "****************\n";
- }
- string GetInput(string item)
- {
- string strInput;
- cout <<"Please enter the " << item << endl;
- cin >> strInput;
- return strInput;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement