Advertisement
Guest User

Untitled

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