Guest User

Untitled

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