Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a c++ program to create a payroll based on following assumptions and requi

ID: 647028 • Letter: W

Question

Write a c++ program to create a payroll based on following assumptions and requirements.

A company called Data Housing Corp. employs a number of employees (say 5) all employees are paid on hourly base, any employee who works more than 40 hours is entitled to be paid overtime (1.5 for every hour exceeding 40).

Calculate :
1. The Gross income=(Rate*hours worked )+ overtime
2. The overtime= No. of hours exceeding 40*Rate*1.5
3. State tax= gross*6%
4.Federal tax=gross*12%
5. Union fees= gross*2%
6. Net= Gross-(State Tax+Federal tax +Union fees)
7. Total Gross for all employees.
8. Average gross

Directions:
Your input consits of:Employee First Name, Middle initial, Last name, Hours worked, Rate per hour.
State tax, fed tax and union fees are constant.
Apply (whatever possible): Loops, constants, data validation, if,else, switch. Each employee must be separated by ----×-----×---.

Explanation / Answer

//C++ Program that prompts first name,middle name
//last name, total hours ,rater per hours
//and calculates the gross income, state tax,
//fed tax and union tax and remaining net income
//and Calculate for 5 employees.
#include<iostream>
#include<string>
using namespace std;

int main()
{
   //declare variables
   string firstName;
   string middleName;
   string lastName;
   char choice;

   //declare integer variables
   int hoursWorked=0;
   int overTime=0;  
   int totalHours=0;

   //declare double variables
   double ratePerHour=0;
   double grossIncome=0;
   double totalGrossIncome=0;
   double netIncome=0;
   double stateTax=0;
   double fedTax=0;
   double unionTax=0;

   //constant declarations
   double STATE_TAX_PERCENTAGE=0.06; //6 %
   double FED_TAX_PERCENTAGE=0.12; //12 %
   double UNION_TAX_PERCENTAGE=0.02;//2%

   //SET number of employees as 5.
   int numberOfEmployees=5;

   //read employee details for 5 persons
   for(int employee=0;employee<numberOfEmployees;employee++)
   {


       //read employee name
       cout<<"Enter your FIRST NAME :";
       cin>>firstName;
       cout<<"Enter your MIDDLE NAME :";
       cin>>middleName;
       cout<<"Enter your LAST NAME :";
       cin>>lastName;

       //read hours worked
       cout<<"Enter HOURS WORKED :";
       cin>>hoursWorked;

       //read rate per hour
       cout<<"Enter RATE PER HOUR :";
       cin>>ratePerHour;

       cout<<"Is employee worked over time ? ";
       cout<<"Enter y for yes , n for no :";
       cin>>choice;

       //check if
       if(choice=='y')
       {
           cout<<"Enter EXTRA HOURS :";
           cin>>overTime;
           //add over time to hoursworked
           totalHours=hoursWorked+overTime;
       }
       else
           totalHours=hoursWorked;

      
       //check if totalHours is less than 40
       if(totalHours<40)
           grossIncome=(ratePerHour*hoursWorked);
       else      
           grossIncome= ratePerHour*40+(totalHours-40)*ratePerHour*1.5;

       //sum all grossIncome for all employess
       totalGrossIncome+=grossIncome;

       //find state tax 6 percent on gross income
       stateTax= grossIncome*STATE_TAX_PERCENTAGE;
       //find federal tax 12 percent on gross income
       fedTax=grossIncome*FED_TAX_PERCENTAGE;
       //find union tax 2 percent on gross income
       unionTax=grossIncome*UNION_TAX_PERCENTAGE;

       //find net income
       netIncome= grossIncome-(stateTax+fedTax+unionTax);

       //Print name of employee
       cout<<"NAME : "<<firstName<<middleName<<lastName<<endl;
      
       //print gross income
       cout<<"Gross Income : $"<<grossIncome<<endl;
       //print state tax
       cout<<"State Tax : $"<<stateTax<<endl;
       //print fed tax
       cout<<"Fed Tax : $"<<fedTax<<endl;
       //print union tax
       cout<<"Union Tax : $"<<unionTax<<endl;
       //print net income
       cout<<"Net Income : $"<<netIncome<<endl;

       cout<<"---------x---------*---------"<<endl;


   }


   //print total gross income
   cout<<"Total gross income : "<<totalGrossIncome<<endl;
   //print average total gross income
   cout<<"Average gross income : "<<totalGrossIncome/numberOfEmployees<<endl;


   //pause program output on console
   system("pause");
   return 0;
}

--------------------------------------------------------------------------------------------------

Sample output:

Enter your FIRST NAME :John
Enter your MIDDLE NAME :D
Enter your LAST NAME :Ditel
Enter HOURS WORKED :40
Enter RATE PER HOUR :5
Is employee worked over time ? Enter y for yes , n for no :y
Enter EXTRA HOURS :10
NAME : JohnDDitel
Gross Income : $275
State Tax : $16.5
Fed Tax : $33
Union Tax : $5.5
Net Income : $220
---------x---------*---------
Enter your FIRST NAME :Mary
Enter your MIDDLE NAME :M
Enter your LAST NAME :Kom
Enter HOURS WORKED :40
Enter RATE PER HOUR :5
Is employee worked over time ? Enter y for yes , n for no :n
NAME : MaryMKom
Gross Income : $200
State Tax : $12
Fed Tax : $24
Union Tax : $4
Net Income : $160
---------x---------*---------
Enter your FIRST NAME :John
Enter your MIDDLE NAME :J
Enter your LAST NAME :Paul
Enter HOURS WORKED :30
Enter RATE PER HOUR :5
Is employee worked over time ? Enter y for yes , n for no :n
NAME : JohnJPaul
Gross Income : $150
State Tax : $9
Fed Tax : $18
Union Tax : $3
Net Income : $120
---------x---------*---------
Enter your FIRST NAME :Ven
Enter your MIDDLE NAME :G
Enter your LAST NAME :Den
Enter HOURS WORKED :40
Enter RATE PER HOUR :5
Is employee worked over time ? Enter y for yes , n for no :y
Enter EXTRA HOURS :10
NAME : VenGDen
Gross Income : $275
State Tax : $16.5
Fed Tax : $33
Union Tax : $5.5
Net Income : $220
---------x---------*---------
Enter your FIRST NAME :Jim
Enter your MIDDLE NAME :C
Enter your LAST NAME :Carry
Enter HOURS WORKED :40
Enter RATE PER HOUR :5
Is employee worked over time ? Enter y for yes , n for no :n
NAME : JimCCarry
Gross Income : $200
State Tax : $12
Fed Tax : $24
Union Tax : $4
Net Income : $160
---------x---------*---------
Total gross income : 1100
Average gross income : 220

Hope this helps you.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote