Guest User

Untitled

a guest
Feb 15th, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.52 KB | None | 0 0
  1. //Program Name: Employee info
  2.  
  3. //Programmer: Trevor England
  4.  
  5. //Date: 2/4/16
  6. //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
  7.  
  8.  
  9. #include <iostream>
  10.  
  11. #include <string>
  12.  
  13. #include <stdlib.h>
  14.  
  15. #include <iomanip>
  16.  
  17. using namespace std;
  18. void DisplayDivider(string);
  19. string GetInput(string);
  20. static int MIN_MANAGEMENT_LEVEL = 0;
  21. static int MAX_MANAGEMENT_LEVEL = 3;
  22. static double MIN_WAGE = 10;
  23. static double MAX_WAGE = 75;
  24. static double MIN_HOURS = 0;
  25. static double MAX_HOURS = 50;
  26. class Benefit
  27. {
  28. private:
  29. string healthinsurance;
  30. double lifeinsurance;
  31. int vacation;
  32. public:
  33. Benefit(){healthinsurance = " ", lifeinsurance = 0, vacation = 0;}
  34. Benefit(string health, double life, int v){healthinsurance = health, lifeinsurance = life, vacation = v;}
  35. void displayBenefits();
  36. string getHealthInsurance(){return healthinsurance;}
  37. void setHealthInsurance(string health){healthinsurance = health;}
  38. double getLifeInsurance(){return lifeinsurance;}
  39. void setLifeInsurance(double life){lifeinsurance = life;}
  40. int getVacation(){return vacation;}
  41. void setVacation(int v){vacation = v;}
  42. };
  43. void Benefit :: displayBenefits()
  44. {
  45. cout << "\nHealth Insurance: " << healthinsurance << endl;
  46. cout << "Life Insurance: " << fixed << setprecision(2) << lifeinsurance << endl;
  47. cout << "Vacation Time: " << vacation << " days" << endl;
  48.  
  49. };
  50.  
  51.  
  52. class employee
  53.  
  54. {
  55. protected:
  56. string firstName,lastName;
  57. int empID, dependents;
  58. char gender;
  59. double annualSalary;
  60. Benefit benefit;
  61. private:
  62. static int numEmployees;
  63. public:
  64. employee(){firstName =" " , lastName = " ", empID = 0, dependents = 0, gender = 'U', annualSalary = 0;}
  65. 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){};
  66. double calcPay(){return annualSalary / 52;}
  67. void displayEmployee();
  68. static int getNumEmployees(){return numEmployees;}
  69. string getFirstName(){return firstName;}
  70. void setFirstName(string first){firstName = first;}
  71. string getLastName(){return lastName;}
  72. void setLastName(string last){lastName = last;}
  73. int getEmpID(){return empID;}
  74. void setEmpID(int ID){empID = ID;}
  75. void setEmpID(string ID) { empID=atoi(ID.c_str()); }
  76. char getGender(){return gender;}
  77. void setGender(char gen){gender = gen;}
  78. void setGender(string gen){gender = gen[0];}
  79. int getDependents(){return dependents;}
  80. void setDependents(int dep){dependents = dep;}
  81. void setDependents(string dep){dependents = atoi(dep.c_str());}
  82. double getAnnualSalary(){return annualSalary;}
  83. void setAnnualSalary(double sal){annualSalary = sal;}
  84. void setAnnualSalary(string sal){annualSalary = atof(sal.c_str());}
  85. void setBenefit(Benefit bfit){benefit = bfit;}
  86. Benefit getBenefit(){return benefit;}
  87. };
  88.  
  89. int employee::numEmployees = 0;
  90. void employee::displayEmployee()
  91. {
  92. cout <<"Name : " << firstName << " " << lastName << endl;
  93. cout <<"Employee ID: " << empID << endl;
  94. cout <<"Gender: " << gender << endl;
  95. cout <<"Dependent: " << dependents << endl;
  96. cout <<"Annual Salary: " << fixed << setprecision(2) << annualSalary << endl;
  97. cout <<"Weekly Salary: " << fixed << setprecision(2) << calcPay() << endl;
  98. numEmployees++;
  99. cout << endl << endl << " Benefit Information" << endl << endl;
  100. benefit.displayBenefits();
  101. }
  102. class Salaried: public employee
  103. {
  104. private:
  105. int MIN_MANAGEMENT_LEVEL;
  106. int MAX_MANAGEMENT_LEVEL;
  107. double BONUS_PERCENT;
  108. int managementLevel;
  109.  
  110.  
  111. public:
  112. Salaried(){BONUS_PERCENT = .1, managementLevel = 0;}
  113. Salaried(int manLevel): employee(firstName,lastName,empID,gender,dependents, benefit, managementLevel(manLevel)){;}
  114. Salaried(double sal, int manLevel){;}
  115. int getManagementLvl(){return managementLevel;}
  116. void setManagementLvl(int manLevel){managementLevel = manLevel;}
  117. double calcPay(){return managementLevel * BONUS_PERCENT;}
  118. void displayEmployee();
  119.  
  120. };
  121.  
  122. void Salaried::displayEmployee()
  123. {
  124. employee::displayEmployee();
  125. cout << "Mgmt Level: " << managementLevel << endl;
  126. cout <<"Annual Salary: " << fixed << setprecision(2) << annualSalary << endl;
  127. cout <<"Weekly Salary: " << fixed << setprecision(2) << calcPay() << endl;
  128.  
  129.  
  130. };
  131. class Hourly : public employee
  132. {
  133. private:
  134. double MIN_WAGE;
  135. double MAX_WAGE;
  136. double MIN_HOURS;
  137. double MAX_HOURS;
  138. double wage;
  139. double hours;
  140. string category;
  141.  
  142. public:
  143. Hourly(){wage = 0, hours = 0, category = "u" ;}
  144. Hourly(double w, double h, string cat){wage = w, hours = h, category = cat ;}
  145. Hourly(double h, double w, string cat): employee(firstName,lastName,empID,gender,dependents, benefit, wage(w), hours(h), category(cat)){;}
  146. double getWage(){return wage;}
  147. void setWage(int w){wage = w;}
  148. double getHours(){return hours;}
  149. void setHours(int h){hours = h;}
  150. string getCategory(){return category;}
  151. void setCategory(int cat){category = cat;}
  152. double calcPay(){return wage * hours;}
  153. void setAnnualSalary(){(wage*hours)* 50;}
  154. void displayEmployee();
  155.  
  156.  
  157. };
  158. void Hourly::displayEmployee()
  159. {
  160. employee::displayEmployee();
  161. cout << "Hourly wage: " << wage << endl;
  162. cout << "Hours: " << hours << endl;
  163. cout << "Category: " << category << endl;
  164. cout <<"Annual Salary: " << fixed << setprecision(2) << annualSalary << endl;
  165. cout <<"Weekly Salary: " << fixed << setprecision(2) << calcPay() << endl;
  166.  
  167. };
  168.  
  169.  
  170.  
  171. void main()
  172.  
  173. {
  174. string input;
  175.  
  176. DisplayDivider("Employee 1");
  177.  
  178. cout << endl << endl ;
  179.  
  180. Benefit benefit1("Aetna", 25000, 15);
  181. employee emp1("Olga", "Ayala", 4059612, 'F', 2, 27000, benefit1);
  182. emp1.displayEmployee();
  183. cout << endl;
  184. cout <<"\n\nNumber of Employees: " << employee::getNumEmployees() << endl;
  185. DisplayDivider("Employee 2");
  186. cout << endl << endl;
  187. Benefit benefit2("Farmers", 60000, 25);
  188. Salaried emp2("Brad", "Pitt", 9977, 'M', 6, 500000, benefit2, 3);
  189. DisplayDivider("Employee Information");
  190. emp2.displayEmployee();
  191. cout << endl;
  192. cout <<"\n\nNumber of Employees: " << employee::getNumEmployees() << endl;
  193. DisplayDivider("Employee 3");
  194. cout << endl << endl;
  195. Benefit benefit3("Met Life", 50000, 12);
  196. Hourly emp3("Joe", "Smith", 3564, 'M', 3, benefit2, 40, 25.50, "Full Time");
  197. DisplayDivider("Employee Information");
  198. emp3.displayEmployee();
  199. cout << endl;
  200. cout <<"\n\nNumber of Employees: " << employee::getNumEmployees() << endl;
  201.  
  202.  
  203.  
  204. system("PAUSE");
  205. }
  206.  
  207. void DisplayDivider(string title)
  208.  
  209. {
  210.  
  211. cout <<"**************** "<< title << "****************\n";
  212.  
  213. }
  214.  
  215.  
  216. string GetInput(string item)
  217.  
  218. {
  219.  
  220. string strInput;
  221. cout <<"Please enter the " << item << endl;
  222. cin >> strInput;
  223. return strInput;
  224.  
  225. }
Advertisement
Add Comment
Please, Sign In to add comment