Advertisement
andrefecto

changed to floats

Nov 18th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.24 KB | None | 0 0
  1. /*
  2. project4.cpp
  3. Andre Fecteau
  4. CSC135-101
  5. November 14, 2013
  6. This program takes in an employee name, hourly rate, and amount of hours worked. It then outputs the amount of taxes taken out.
  7. */
  8. #include <iostream>
  9. #include <string>
  10. using namespace std;
  11. /*
  12. Basic Function for Copy Paste
  13. <function type> <function name> (){
  14.  
  15. // Declarations
  16. // Initalizations
  17. // Input
  18. // Process
  19. // Output
  20. // Prolouge
  21. }
  22. */
  23. void displayInfo(){
  24. // Declarations
  25. // Initalizations
  26. // Input
  27. // Process
  28. // Output
  29. cout <<"| ------------------------------------------------------------------------- |" << endl;
  30. cout <<"| ------ Welcome to the employee pay and tax calculator ------------------- |" << endl;
  31. cout <<"| ------------------------------------------------------------------------- |" << endl;
  32. cout <<"| This program will take in the employees name                              |" << endl;
  33. cout <<"| Take in their hourly rate                                                 |" << endl;
  34. cout <<"| Take in the hours worked                                                  |" << endl;
  35. cout <<"| Then calculate tax and total earnings post tax and output the information |" << endl;
  36. cout <<"| ------------------------------------------------------------------------- |" << endl;
  37. cout << endl;
  38. // Prolouge
  39. }
  40. string employeeName(){
  41. // Declarations
  42. string name;
  43. // Initalizations
  44. name = ' ';
  45. // Input
  46. cout << "Please enter employee name (First and last with space is accepted): ";
  47. getline (cin, name);
  48. cout << endl;
  49. // Process
  50. // Output
  51. // Prolouge
  52. return name;
  53. }
  54. float hourlyRate(){
  55. // Declarations
  56. float rate;
  57. // Initalizations
  58. rate = 0;
  59. // Input
  60. // Process
  61. cout << "Please enter the hourly rate for the employee: ";
  62. cin >> rate;
  63. // Output
  64. // Prolouge
  65. return rate;
  66. }
  67. float hoursWorked(){
  68. // Declarations
  69. float hours;
  70. float temp;
  71. float running;
  72. // Initalizations
  73. hours = 0;
  74. running = 0;
  75. temp = 0;
  76. // Input
  77. for(int counted = 1; counted < 6; counted++)
  78.         {
  79.             cout << "Please enter the amount of hours worked on day " << counted << ": ";
  80.             cin >> hours;
  81.             running = hours + temp;
  82.             temp = running;
  83.             cout << endl;
  84.         }
  85. return temp;
  86. }
  87. float doCalculations(float hourlyRate, float hoursWorked){
  88. // Declarations
  89. float gross;
  90. float precentage;
  91. float withholdingAmount;
  92. float net;
  93. // Initalizations
  94. gross = 0;
  95. precentage = 0;
  96. withholdingAmount = 0;
  97. net = 0;
  98. // Input
  99. // Process
  100. gross = hourlyRate * hoursWorked;
  101. if(gross < 500){precentage = 23.7;}
  102. if(gross >= 500){precentage = 33.9;}
  103. withholdingAmount = precentage / gross * 100;
  104. net = gross - withholdingAmount;
  105. // Output
  106. // Prolouge
  107. return net;
  108. }
  109. void outputInfo(float doCalculations, float hoursWorked, float hourlyRate, string employeeName){
  110. // Declarations
  111. float outGross;
  112. float outWithHeld;
  113. // Initalizations
  114. outGross = 0.0;
  115. outWithHeld = 0.0;
  116. // Input
  117. // Process
  118. outGross = hoursWorked * hourlyRate;
  119. outWithHeld = outGross - doCalculations;
  120. // Output
  121. cout <<"| ------------------------------------------------------------------------- |" << endl;
  122. cout <<"| ----------------------- Calculation Totals ------------------------------ |" << endl;
  123. cout <<"| ------------------------------------------------------------------------- |" << endl;
  124. cout << "          Employee Name: "<< employeeName << endl;
  125. cout << "              Gross Pay: "<< outGross << endl;
  126. cout << "Total Witholding Amount: "<< outWithHeld <<endl;
  127. cout << "                Net Pay: "<< doCalculations << endl;
  128. cout <<"| ------------------------------------------------------------------------- |" << endl;
  129. cout <<"| ------------------------------------------------------------------------- |" << endl;
  130. // Prolouge
  131. }
  132. int main(){
  133. // Declarations
  134. string done;
  135. string nameOf;
  136. float hourRate;
  137. float worked;
  138. float calcs;
  139. // Initalizations
  140. done = "done";
  141. nameOf = " ";
  142. hourRate = 0;
  143. worked = 0;
  144. calcs = 0;
  145. // Input
  146. displayInfo();
  147. while( nameOf != done)
  148. {
  149.     nameOf = employeeName();
  150.     if(nameOf == done){break;}
  151.     hourRate = hourlyRate();
  152.     worked = hoursWorked();
  153.     calcs = doCalculations(hourRate, worked);
  154.     outputInfo(calcs, hourRate, worked, nameOf);
  155.     cin.ignore();
  156. }
  157. cout << "was done";
  158. // Process
  159. // Output
  160. // Prolouge
  161. return 0;
  162. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement