fork download
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. void getInput(string &name, float &weekly_Pay){
  8. cout << "Please enter customer name" << endl;
  9. cin >> name;
  10. cout << "Enter weekly salary" << endl;
  11. cin >> weekly_Pay;
  12. }
  13.  
  14. void calcFedTaxes(float weekly_Pay, float PIT_Rate, float SOSEC_Rate, float &PIT, float &SOSEC){
  15. PIT = weekly_Pay * PIT_Rate;
  16. SOSEC = weekly_Pay * SOSEC_Rate;
  17. }
  18.  
  19. void calcNetPay(float weekly_Pay, float PIT, float SOSEC, float &weekly_Net_Pay){
  20. weekly_Net_Pay = weekly_Pay - (PIT + SOSEC);
  21. }
  22.  
  23. void displayInfo(string name, float PIT, float SOSEC, float weekly_Net_Pay){
  24. cout << "Customer name is:" << name << endl;
  25. cout << "PIT is:" << PIT << endl;
  26. cout << "SOSEC is:" << SOSEC << endl;
  27. cout << "Weekly Pay is:" << weekly_Net_Pay << endl;
  28. }
  29.  
  30. int main(){
  31. char response = 'n';
  32. string name ="";
  33. float weekly_Pay = 0.0;
  34. float weekly_Net_Pay = 0.0;
  35. const float PIT_RATE = (0.2);
  36. const float SOSEC_RATE = (0.08);
  37. float SOSEC = (0.0);
  38. float PIT = (0.0);
  39.  
  40. do {
  41. getInput(name, weekly_Pay);
  42. calcFedTaxes (weekly_Pay, PIT_RATE, SOSEC_RATE, PIT, SOSEC);
  43. calcNetPay (weekly_Pay, PIT, SOSEC, weekly_Net_Pay);
  44. displayInfo (name, PIT, SOSEC, weekly_Net_Pay);
  45.  
  46. cout << "Enter n or N to end:";
  47. cin >> response;
  48. cout << endl;
  49. }
  50. while (!((response == 'n') || (response == 'N')));
  51. }
Success #stdin #stdout 0s 4256KB
stdin
Joe 123.45 N
stdout
Please enter customer name
Enter weekly salary
Customer name is:Joe
PIT is:24.69
SOSEC is:9.876
Weekly Pay is:88.884
Enter n or N to end: