Advertisement
andrefecto

Won't compile

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