#include <iostream>
#include <iomanip>
usingnamespace std;
void get_emp_rec(int &id, double &prate, double &hours)
{
cout << "Employee ID is:\t";
cin >> id;
cout << "Payrate is:\t";
cin >> prate;
cout << "Hours worked are:\t";
cin >> hours;
}
double compute_gpay(double hours, double prate)
{
double gpay; // to hold the gross pay
gpay= hours * prate;
return (gpay);
}
double compute_taxes(double gpay)
{
double td; // to hold the tax deduction
if (gpay <= 1000)
td = gpay * 0.05;
elseif(gpay < 1500)
td= gpay * 0.06;
else
td= gpay * 0.07;
return(td);
}
double compute_npay(double gpay)
{
double npay, td;
td=compute_taxes(gpay);
npay = gpay - td;
return (npay);
}
void printtables(int ids[], double gpays[], double npays[], int size)
{
for(int j=0; j<10;j++)
{
cout << "Enter an ID:";
cin >> ids[j];
cout << "Enter gross pay:";
cin >> gpays [j];
cout << "Enter net pay:";
cin >> npays [j];
}
}
int main()
{
int id=0; // to hold the employee ID number
double gross; // to hold the gross pay
double payr; // to hold the payrate
double hoursW; // to hold the number of hours
double tax; // to hold the tax deduction
double netp=0; // to hold the net pay
double tgross=0; // to hold the total gross pay
double tnet; // to hold the total net pay
int count=1; // to count the number of employees
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout << setprecision(2); // 2 digits after the decimal point
while (count <= 10)
{
get_emp_rec(id, payr, hoursW);
cout << "\nEmployees records:\t" << id;
/**********************Compute the gross pay*******************************/
gross= compute_gpay(hoursW, payr);
cout << "\nGross Pay:\t" << gross;
/*********************Compute net pay**************************************/
netp= compute_npay (gross);
cout << "\nNet Pay:\t"<< netp;
/********************Compute the total gross and net pay*******************/
tgross = tgross + gross;
tnet = tnet + netp;
cout << endl;
cout << endl;
count= count+1;
int empid[10];
double empgrosspay[10];
double empnetpay[10];
printtables(ids, gross, netp);
}
/************************Print the total gross and net pay*********************/
cout << endl << "\nTotal Gross Pay:\t" << tgross;
cout << endl << "\n Total Net Pay:\t" << tnet;
cout << endl;
system ("PAUSE");
return 0;
}
you need three arrays of 10 elements: int empid[10](to hold all employees id numbers), double emgrosspay[10] (to hold all employees' gross pays) and double empnetpay[10](to hold all emploees' net pays). These arrays are declared in the main function.
You've declared three arrays within your while loop. This means that, on every iteration of that loop, they will be created, and then be destroyed again as they fall out of scope.
Is that what you intended? Nothing in your code ever sets any values in those arrays, nor attempts to use the values in those arrays, so it's impossible to tell from your code.