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

OBJECT: To compute the payroll in a company of 10 employees, given an employee\'

ID: 645247 • Letter: O

Question


OBJECT: To compute the payroll in a company of 10 employees, given an employee's pay rate, number of hours, and tax rate. For each employee, you will compute his/her gross pay, tax deduction, and net pay. You will also Compute and print the total gross pay and the total tax deduction of the company and print them. INPUT: For each employee, his pay rate and number of hours. You will prompt the user with a friendly message to enter an employee's pay rate and number of hours, OUTPUT: For each employee, his/her gross pay, tax deduction, and net pay. For example: Also print at the end, the total gross pay and the total tax deduction for the company. METHOD: For each employee, the gross pay is the pay rate times the number of hours; The tax deduction is computed as follows: If the gross pay is less than 1000.00, it is 5% of the gross pay: otherwise it is 6% of the gross pay. The net pay is the gross pay minus the tax deduction. TOPICS: arithmetic operations, input with cin, formatted output with cout, program documentation and style, while and if/else structures.

Explanation / Answer

//Program for Employee payroll
#include <iostream>
using namespace std;

struct Employee{
   float empPayRate;
   int noh;
   float taxRate;
};

int main()
{
   struct Employee e[10];
   float grossPay[10],netPay[10],totalGrossPay=0,totalTax=0;
   int i=0;
   cout<<" Enter 10 Employee's data : ";
  
   //Input and process of calcuations
  
   while(i<10)
   {
       cout<<" Enter "<<(i+1)<<" Employee PayRate and No.of Hours ";
       cin>>e[i].empPayRate>>e[i].noh;
      
       //Calculation of each employee grosspay
       grossPay[i]=(e[i].empPayRate*e[i].noh);
      
       //Calculation of tax Rate field
       if(grossPay[i]<1000)
       e[i].taxRate=grossPay[i]*5/100;
       else
       e[i].taxRate=grossPay[i]*5/100;
      
       //Calculation of each employee netPay
       netPay[i]=grossPay[i]-e[i].taxRate;
      
       //Calculation of totalGrosspay and totalTax
       totalGrossPay+=grossPay[i];
       totalTax+=e[i].taxRate;
      
       //increase in index value of arrays
       i++;
   }
  
   // Final formatted output
   i=0;
  
      
   //Printing title
   cout.width(15);cout<<"Employee Pay Rate";
   cout.width(10);cout<<"No.of Hours";
   cout.width(10);cout<<"Grosss Pay";
   cout.width(10);cout<<"Tax Rate";
   cout.width(10);cout<<"Net Pay"<<endl;
  
   // Printing 10 employee's data
  
   while(i<10)
   {
   cout.width(15);cout<<e[i].empPayRate;
   cout.width(10);cout<<e[i].noh;
   cout.width(10);cout<<grossPay[i];
   cout.width(10);cout<<e[i].taxRate;
   cout.width(10);cout<<netPay[i]<<endl;
   i++;
   }
  
   //Printing total gross
   cout.width(35);cout<<totalGrossPay;
   cout.width(10);cout<<totalTax<<" of the Company"<<endl;
return 0;
}