fork download
  1. #include <iostream>
  2. #include <string.h>
  3.  
  4. using namespace std;
  5.  
  6. class Employee
  7. {
  8. public:
  9. string Emp_Name;
  10. int Join_Year;
  11. int Emp_age;
  12. int Emp_id;
  13.  
  14. public:
  15.  
  16. void Accept()
  17. {
  18. cout<<"Enter Employee ID : "<<endl;
  19. cin>>Emp_id;
  20. cout<<"Enter Employee name : "<<endl;
  21. cin>>Emp_Name;
  22. cout<<"Enter Employee age : "<<endl;
  23. cin>>Emp_age;
  24. cout<<"Enter Employee join Year : "<<endl;
  25. cin>>Join_Year;
  26.  
  27. }
  28. void Display_Emp_detail()
  29. {
  30. cout<<"Employee ID : "<<Emp_id<<endl;
  31. cout<<"Employee name : "<<Emp_Name<<endl;
  32. cout<<"Employee age : "<<Emp_age<<endl;
  33. cout<<"Employee join Year : "<<Join_Year<<endl;
  34. }
  35. };
  36.  
  37. class Admin : public Employee
  38. {
  39. protected:
  40. double Emp_Basic_Salary;
  41. int Emp_OT_Hour;
  42. float Emp_OT;
  43. float Emp_Overtime_Pay , Emp_Tax_Rate;
  44. float Emp_Gross_Pay , Emp_Net_Pay;
  45. float Emp_Annual_Pay;
  46. int Total_Exp;
  47. int Emp_leave;
  48.  
  49. public:
  50. void Accept1()
  51. {
  52. Accept();
  53. cout<<"Enter Monthly salary : ";
  54. cin>>Emp_Basic_Salary;
  55.  
  56. cout<<"Enter Over Time in hours : ";
  57. cin>>Emp_OT_Hour;
  58.  
  59. cout<<"Enter Absenties : ";
  60. cin>>Emp_leave;
  61.  
  62.  
  63.  
  64. }
  65. void Overtime_Pay();
  66. void Tax_Rate();
  67. void Pay_Grade();
  68. void Emp_Payment();
  69. void Emp_Yearly_Payment();
  70. void Emp_Experience_Count();
  71. void Emp_Retire_Year();
  72. void Emp_Leave_Pay();
  73.  
  74. };
  75.  
  76. void Admin :: Overtime_Pay()
  77. {
  78. Emp_OT = Emp_Basic_Salary * .01;
  79. Emp_Overtime_Pay = Emp_OT_Hour * Emp_OT;
  80.  
  81. cout<<"Overtime Money is : "<<Emp_Overtime_Pay<<endl;
  82. }
  83.  
  84.  
  85. void Admin :: Tax_Rate()
  86. {
  87. if(Emp_Basic_Salary < 10000)
  88. {
  89. Emp_Tax_Rate = Emp_Basic_Salary * .05; // .05 means 5%
  90. cout<<"Withholding Tax :"<<Emp_Tax_Rate<<endl;
  91. }
  92. if(Emp_Basic_Salary >= 10000 && Emp_Basic_Salary <= 20000)
  93. {
  94. Emp_Tax_Rate = Emp_Basic_Salary * .10; // .10 means 10%
  95. cout<<"Withholding Tax :"<<Emp_Tax_Rate<<endl;
  96. }
  97. else if(Emp_Basic_Salary >= 20000 && Emp_Basic_Salary <=30000)
  98. {
  99. Emp_Tax_Rate = Emp_Basic_Salary * .15;
  100. cout<<"Withholding Tax :"<<Emp_Tax_Rate<<endl;
  101. }
  102. else if(Emp_Basic_Salary >= 30000 && Emp_Basic_Salary <= 40000)
  103. {
  104. Emp_Tax_Rate = Emp_Basic_Salary * .20;
  105. cout<<"Withholding Tax :"<<Emp_Tax_Rate<<endl;
  106. }
  107. else if(Emp_Basic_Salary >= 40000 && Emp_Basic_Salary <= 50000)
  108. {
  109. Emp_Tax_Rate = Emp_Basic_Salary * .25;
  110. cout<<"Withholding Tax : "<<Emp_Tax_Rate<<endl;
  111. }
  112. else if(Emp_Basic_Salary > 50000)
  113. {
  114. Emp_Tax_Rate = Emp_Basic_Salary * .30;
  115. cout<<"Withholding Tax : "<<Emp_Tax_Rate<<endl;
  116. }
  117. }
  118.  
  119.  
  120. void Admin :: Pay_Grade()
  121. {
  122. if(Emp_Basic_Salary <= 10000)
  123. {
  124. cout << "Employee Pay Grade is "<<"F" << endl;
  125.  
  126. }
  127. else if(Emp_Basic_Salary >= 10001 && Emp_Basic_Salary <= 20000)
  128. {
  129. cout << "Employee Pay Grade is " << "E" << endl;
  130.  
  131. }
  132. else if(Emp_Basic_Salary >= 20001 && Emp_Basic_Salary <=30000)
  133. {
  134. cout << "Employee Pay Grade is " << "D" << endl;
  135.  
  136. }
  137. else if(Emp_Basic_Salary >= 30001 && Emp_Basic_Salary <= 40000)
  138. {
  139. cout << "Employee Pay Grade is " << "C" << endl;
  140.  
  141. }
  142. else if(Emp_Basic_Salary >= 40001 && Emp_Basic_Salary <= 50000)
  143. {
  144. cout << "Employee Pay Grade is " << "B" << endl;
  145.  
  146. }
  147. else
  148. {
  149. cout << "Employee Pay Grade is " << "A" << endl;
  150. }
  151. }
  152.  
  153.  
  154. void Admin :: Emp_Payment()
  155. {
  156. Emp_Gross_Pay = Emp_Basic_Salary + Emp_Overtime_Pay;
  157. Emp_Net_Pay = Emp_Gross_Pay - Emp_Tax_Rate;
  158.  
  159. cout<<"Gross Payment : "<<Emp_Gross_Pay<<endl; //Without Tex Payment
  160. cout<<"Net Payment : "<<Emp_Net_Pay<<endl;
  161. }
  162.  
  163.  
  164. void Admin :: Emp_Yearly_Payment()
  165. {
  166. Emp_Annual_Pay = 12 * Emp_Basic_Salary;
  167. cout<<"Annual Income : "<<Emp_Annual_Pay<<endl;
  168. }
  169.  
  170.  
  171. void Admin::Emp_Experience_Count()
  172. {
  173.  
  174. Total_Exp = 2020 - Join_Year;
  175.  
  176. cout<<"Total work experience:"<< Total_Exp <<" years" <<endl;
  177. }
  178.  
  179. void Admin :: Emp_Retire_Year()
  180. {
  181.  
  182. if(Emp_age<60)
  183. {
  184. int Remaining_year=60-Emp_age;
  185. cout<<endl<<"Employee remaining year : "<<Remaining_year<<endl;
  186. }
  187. else
  188. {
  189.  
  190. cout<<endl<<" Employee retired "<<endl;
  191. }
  192.  
  193. }
  194.  
  195. void Admin :: Emp_Leave_Pay()
  196. {
  197. float Payment_with_leave,Leave;
  198. Leave = Emp_Basic_Salary * .01;
  199.  
  200. Payment_with_leave = Emp_leave * Leave;
  201. cout<<"Absents Salary cut : "<< Payment_with_leave<<endl;
  202. }
  203.  
  204. int main()
  205. {
  206.  
  207.  
  208. Admin emp;
  209.  
  210. // emp.Accept();
  211. emp.Accept1();
  212.  
  213. emp.Display_Emp_detail();
  214. cout<<"\n-----------------------------------------------"<<endl;
  215.  
  216.  
  217.  
  218.  
  219.  
  220. //PayRoll emp(name ,Emp_age, OTHour , BasicSalary , JoinYear , Leaves);
  221.  
  222. cout<<"\n------------------------------------------------"<<endl;
  223. emp.Overtime_Pay();
  224.  
  225. cout<<"\n------------------------------------------------"<<endl;
  226. emp.Emp_Leave_Pay();
  227.  
  228.  
  229. cout<<"\n*****************"<<endl;
  230. emp.Pay_Grade();
  231.  
  232.  
  233. cout<<"\n------------------------------------------------"<<endl;
  234. emp.Tax_Rate();
  235.  
  236. cout<<"\n------------------------------------------------"<<endl;
  237. emp.Emp_Payment();
  238.  
  239. cout<<"\n------------------------------------------------"<<endl;
  240. emp.Emp_Yearly_Payment();
  241.  
  242.  
  243. cout<<"\n------------------------------------------------"<<endl;
  244. emp.Emp_Experience_Count();
  245.  
  246. cout<<"\n------------------------------------------------"<<endl;
  247. emp.Emp_Retire_Year();
  248.  
  249.  
  250.  
  251. return 0;
  252. }
Success #stdin #stdout 0s 4540KB
stdin
Standard input is empty
stdout
Enter Employee ID          : 
Enter Employee name        : 
Enter Employee age         : 
Enter Employee join Year   : 
Enter Monthly salary     : Enter Over Time in hours : Enter Absenties          : Employee ID          : -1039195559
Employee name        : 
Employee age         : 21924
Employee join Year   : -1039196152

-----------------------------------------------

------------------------------------------------
Overtime Money is : 0

------------------------------------------------
Absents Salary cut : 0

*****************
Employee Pay Grade is F

------------------------------------------------
Withholding Tax :0

------------------------------------------------
Gross Payment : 0
Net Payment : 0

------------------------------------------------
Annual Income : 0

------------------------------------------------
Total work experience:1039198172 years

------------------------------------------------

 Employee retired