Professional Documents
Culture Documents
Payrollsys
Payrollsys
Payrollsys
Montemayor
The program should find the minimum and maximum net pay of all employees as well as sort the
employees based on their net pay (ascending order)
#include<fstream>
#include<iostream>
#include<iomanip>
using namespace std;
int totalEmployeeCount,hrs,employeeCounter,stat,empID;
double rate,regPay;
string fName;
string lName;
class employee{
public:
double salary,hourlyRate,taxRate,taxAmount,grossPay,netPay,otPay;
int hours,otHours;
double calculateNetPay(){
netPay = grossPay - taxAmount;
return netPay;
} // END CALCULATENETPAY() FUNCTION.
void printData(){
cout<<setprecision(2)<<setiosflags(ios::fixed | ios::showpoint);
cout<<fName<<setw(6)<<lName<<setw(6)<<empID<<setw(10)<<hrs<<setw(3)
<<otHours<<setw(8)<<grossPay<<setw(8)<<netPay<<setw(8)<<otPay<<endl;}
// END PRINTDATA() FUNCTION
}; // END EMPLOYEE CLASS
int main(){
int employeeCounter;
cout<< "enter # of employees you want to process: ";
cin>>totalEmployeeCount;
employee*employee[100];
while(employeeCounter < totalEmployeeCount){
cout<<"Is employee "<<employeeCounter+1<< " hourly or salary? (enter 1
for hourly / 2 for salary):";
cin>>stat;
if (stat == 1){cout<< "Instantiating and HOURLY employee object
inherited from base class employee"
<<endl<<endl;
cout<<"Enter employee's ID: ";
cin>>empID;
cout<<"Enter employee's first name: ";
cin>>fName;
cout<<"Enter employee's last name: ";
cin>>lName;
cout<<"Enter employee's hourly wage: ";
cin>>rate;
cout<<"Enter employee's hours for this week: ";
cin>>hrs;
employee[employeeCounter] = new employeeHourly();
employee[employeeCounter]->setVariables(empID, fName, lName, stat,
rate, hrs);
employee[employeeCounter]->calculateGrossPay();
employee[employeeCounter]->calculateTaxAmount();
employee[employeeCounter]->calculateNetPay();
cout<<endl<<endl;
employeeCounter++; } //end if