By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,385 Members | 1,135 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,385 IT Pros & Developers. It's quick & easy.

c++ program that will process payroll for employees

P: 1
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. const float STATE_TAX_RATE = .07;
  7. const float FEDERAL_TAX_RATE = .15;
  8. const float SOCIAL_SECURITY = .17;
  9. const float MEDICAL = .03;
  10.  
  11. int main ()
  12. {
  13.     // local declartion section
  14.     string Employee_first_name;
  15.     int Number_of_Hours;
  16.     float Hourly_Pay_Rate;
  17.     float Gross_Pay;
  18.     float Net_Pay;
  19.     string Deduction_Type;
  20.     float Deduction_Rate;
  21.     float Deduction_Amount;
  22.     float State_tax_rate;
  23.     float Federal_tax_rate;
  24.     float Social_Security;
  25.     float Medical;
  26.     int shift;
  27.     float bonus_amount;
  28.  
  29.     // input section
  30.     cout<<" enter Employee first name : ";
  31.     cin>>Employee_first_name;
  32.     cout<<" enter Number of Hours: ";
  33.     cin>>Number_of_Hours;
  34.     if(Number_of_Hours<=40)
  35.     {
  36.       cout<<"Gross_Pay=Number_of_Hours*Pay_Rate";
  37.     } else{
  38.     cout<<"Gross_Pay=Number_of_Hours*Pay_Rate*1.5";
  39.     }
  40.     cout<<" enter Pay Rate: ";
  41.     cin>>Hourly_Pay_Rate;
  42.     cout<<" enter employee shift: ";
  43.     cin>>shift;
  44.      if(shift==1)
  45.     {
  46.     bonus_amount=0;
  47.     }
  48.     else if (shift==2)
  49.     {
  50.     bonus_amount=Gross_Pay*0.1;
  51.     }
  52.     else if (shift==3)
  53.     {
  54.     bonus_amount=Gross_Pay*0.2;
  55.     }
  56.     cout<<" Deduction Type: ";
  57.     cin>>Deduction_Type;
  58.  
  59.  
  60.  
  61.     // process section
  62.     float State_Taxes=Gross_Pay*.07;
  63.     float Federal_Taxes=Gross_Pay*.15;
  64.     Social_Security=Gross_Pay*.17;
  65.     Medical=Gross_Pay*.03;
  66.     Gross_Pay= Number_of_Hours* Hourly_Pay_Rate;
  67.     float Total_Deduction=State_Taxes+ Federal_Taxes+Social_Security+Medical;
  68.     Net_Pay=(Gross_Pay+bonus_amount)-Total_Deduction;
  69.  
  70.  
  71.     // output section
  72.  
  73.     cout<<setiosflags(ios::fixed | ios::showpoint);
  74.     cout<<setprecision(2);
  75.     cout<<"Employee Name"<<Employee_first_name<<"Hours Worked"<<Number_of_Hours<<"Pay rate"<<Hourly_Pay_Rate<<"Gross Pay"<<Gross_Pay<<"Net Pay"<<Net_Pay<<endl;
  76.     //cout<<setw(15)<<length;
  77.     cout<<"Deduction Type"<<Deduction_Type<<"Deduction Rate"<<Deduction_Rate<<"Deduction Amount"<<Deduction_Amount<<endl;
  78.     cout<<"=============================="<<endl;
  79.     cout<<left<<setw(15)<<"State Taxes"<<right<<setw(15)<<State_tax_rate<<endl;
  80.     cout<<left<<setw(15)<<"Federal Taxes"<<right<<setw(15)<<Federal_tax_rate<<endl;
  81.     cout<<left<<setw(15)<<"Social Security"<<right<<setw(15)<<Social_Security<<endl;
  82.     cout<<left<<setw(15)<<"Medical"<<right<<setw(15)<<Medical<<endl;
  83.     cout<<"your shift is"<<shift<<endl;
  84.      cout<<"your bonus amount is"<<bonus_amount<<endl;
  85.  
  86.      int x;
  87.    cin>>x; 
  88.     return 0;
  89. }
3 Weeks Ago #1
Share this Question
Share on Google+
1 Reply

Banfa
Expert Mod 5K+
P: 8,996
Do you have a question?
3 Weeks Ago #2

Post your reply

Sign in to post your reply or Sign up for a free account.