OBJECT: To compute the payroll in a company of 10 employees, given an employee\'
ID: 645247 • Letter: O
Question
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;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.