Guest User

Untitled

a guest
May 16th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. /*
  2. Write a program that displays a weekly payroll report.
  3. A loop in the program should ask the user for the employee number, gross pay, state tax, federal tax, and FICA witholdings.
  4. The loop will terminate when 0 is entered fir the employee number.
  5. After the data is entered, the program should display totals for gross pay, state tax, federal tax, FICA witholdings and net pay.
  6. Validation: Do not accept negative numbers for any of the items entered.
  7. Do not accept values for state, federal or FICA that are greater than the gross pay.
  8. If the sum state tax + FICA for any employee is greater than gross pay,
  9. print an error message and ask the user to re-enter the data for that employee.
  10.  
  11. */
  12.  
  13.  
  14.  
  15.  
  16. #include <iostream>
  17. using namespace std;
  18. main()
  19. {
  20. int empnum = 1 ;
  21. double grossPay = 0.0 ,stax = 0.0 ,ftax = 0.0 ,fitax = 0.0 , netpay= 0.0;
  22.  
  23. while(empnum != 0 )
  24. {
  25.  
  26. cout<<"Please Enter employye ID : "<<endl;
  27. cin>>empnum;
  28. if(empnum != 0 ){
  29. double empgrosspay = 0.0 , empstax = 0.0 , empftax = 0.0 , empfitax= 0.0 ;
  30. double plustax = empstax + empfitax ;
  31. bool wrong ;
  32.  
  33.  
  34. do{
  35. // EMPLOYEE GROSS PAY
  36. cout<<"Please Enter Employee Gross Pay : " << endl;
  37. cin>> empgrosspay;
  38. // EMPLOYEE STATE TAX
  39. cout<<"Please Enter Employee State Tax : " << endl;
  40. cin>> empstax;
  41. //EMPLOYEE FEDRAL TAX
  42. cout<<"Please Enter Employee Federal Tax : " << endl;
  43. cin>> empftax;
  44. //EMPLOYEE FICA TAX
  45. cout<<"Please Enter Employee FICA Tax : " << endl;
  46. cin>> empfitax;
  47. // CHECK THE NEGATIVE NUMBERS
  48. if(empgrosspay < 0 || empstax < 0 || empftax < 0 || empfitax < 0)
  49. {
  50. cout<<"**** Wrong Data Check Your Numbers **** " << endl;
  51. wrong = true;
  52. }
  53. //CHECK THE GROSS PAY BIGGER THAN OTHERS
  54. else if (empstax > empgrosspay || empftax > empgrosspay || empfitax > empgrosspay){
  55. cout<<"*** Your Taxes Can Not Be More Than Your Gross Pay " <<endl;
  56. wrong = true;
  57. }
  58. //CHECK THE SUM OF FICA + STATE TAX
  59. else if(plustax > empgrosspay){
  60. cout<<"*** Your State and FICA Taxes are More Than Your Gross Pay " <<endl;
  61. wrong = true;
  62. }
  63.  
  64. else
  65. wrong = false;
  66.  
  67.  
  68. } while(wrong);
  69.  
  70.  
  71.  
  72. grossPay = empgrosspay ;
  73. stax = empstax ;
  74. ftax = empftax ;
  75. fitax = empfitax ;
  76. netpay = empgrosspay - (stax + ftax + fitax) ;
  77.  
  78. }
  79.  
  80. }
  81. cout<<" The Net Pay Is $ "<< netpay<< endl;
  82. cout<<"Gross Pay total is : $ "<< grossPay << endl;
  83. cout<<"State Pay total is : $ "<< stax << endl;
  84. cout<<"Fedral Pay total is : $ "<< ftax << endl;
  85. cout<<"FICA Pay total is : $ " << fitax << endl;
  86.  
  87. return 0;
  88. }
Add Comment
Please, Sign In to add comment