Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. #include <ctime>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int GetSalary(int,int,int,int);
  7. int GetYearsOfService(int);
  8.  
  9.  
  10. int main()
  11. {
  12. int employeeId, hoursWorked, yearJoined, fullTime;
  13.  
  14. cout << "Employee ID: ";
  15. cin >> employeeId;
  16.  
  17. cout << "Hours Worked: ";
  18. cin >> hoursWorked;
  19.  
  20. cout << "Year Joined: ";
  21. cin >> yearJoined;
  22.  
  23. cout << "FullTime Status (0 for no, 1 for yes): ";
  24. cin >> fullTime;
  25.  
  26. double salary = GetSalary(employeeId, hoursWorked, yearJoined, fullTime);
  27. double taxes = salary * 0.15;
  28.  
  29. cout << endl << "Empolyee ID: " << employeeId << endl << "tFull time?: ";
  30.  
  31. if (fullTime == 0)
  32. cout << "No";
  33. else
  34. cout << "Yes";
  35.  
  36. cout << endl << "tHours worked: " << hoursWorked << endl << "tWages (after tax) for the month: $"
  37. << salary - taxes << endl << "tAmount withheld for tax: $" << taxes;
  38.  
  39. return 0;
  40. }
  41.  
  42. int GetSalary(int employeeId, int hoursWorked, int yearJoined, int fullTime) {
  43. double hourlyWage = 14;
  44.  
  45. //Get the hourly wage
  46. int wage = 14;
  47.  
  48. if( wage>=50 && wage < 100){
  49. wage += 1.25;
  50. }else if( wage < 160){
  51. wage += 2.0;
  52. }else{
  53. wage += 3.0;
  54. }
  55.  
  56. double baseSalary = hourlyWage * hoursWorked;
  57. int yearsOfService = GetYearsOfService(yearJoined);
  58.  
  59. //Check if any additional benefits/bonusses are to be paid
  60. if (fullTime == 1)
  61. {
  62. baseSalary += (35 *yearsOfService);
  63. baseSalary += 300;
  64. }
  65. else {
  66. if (yearsOfService > 5)
  67. baseSalary += (35 * yearsOfService);
  68. }
  69. return baseSalary;
  70. }
  71.  
  72. int GetYearsOfService(int yearJoined) {
  73. time_t curTime = time(NULL);
  74.  
  75. int elapsed = curTime / (365 * 24 * 60 * 60);
  76.  
  77. return 1970 + elapsed - yearJoined;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement