1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
// weekly Time Card program
// ChrisH
// 4/27/12
// this program computes pay for all employees
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;
//Function prototypes
void inputEmployeeInfo (string[], float[], float[], int, int );
void computePay (float, float[], float[], float[], float[],int, int );
void outputPayReport ( string[], float[], float[], float[], float[], int );
/////////////////////
int main()
{
int numOfEmps;
int size;
size = numOfEmps;
cout <<"Enter the number of Employees you wish to calculate pay for:" << endl; // initializing array size numOfEmps
cin >> size;
int counter;
string names[numOfEmps];
float hours[numOfEmps];
float payrate[numOfEmps];
float grossPay[numOfEmps];
float netPay[numOfEmps];
float OTpay;
//calling functions
void inputEmployeeInfo ( names[numOfEmps], hours[numOfEmps], payrate[numOfEmps], numOfEmps );
void computePay ( OTpay[numOfEmps],grossPay[numOfEmps], netPay[numOfEmps], hours[numOfEmps], payrate[numOfEmps],counter, numOfEmps );
void outputPayReport ( names[numOfEmps], hours[numOfEmps], payrate[numOfEmps], grossPay[numOfEmps], netPay[numOfEmps], numOfEmps);
return 0;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////start funtion 1
void inputEmployeeInfo ( string names[], float hours[], float payrate[], int numOfEmps )
{
int counter = 0;
ofstream outputFile;
outputFile.open ("empInfo.txt");
while (counter < numOfEmps)
{
cout << "Enter the name of an employee:" << endl;
cin >> names[counter];
cout << "Enter the hourly pay rate for this employee:" << endl;
cin >> payrate[counter];
cout << "Enter the hours this employee worked this week:" << endl;
cin >> hours[counter];
outputFile << names[counter] << endl;
outputFile << payrate[counter] << endl;
outputFile << hours[counter] << endl;
outputFile.close();
counter++;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////end function 1
//
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////start function 2
void computePay(float OTpay, float grosspay[], float netpay[], float hours[], float payrate[],int counter, int numOfEmps )
{
int index = 0;
while (index < counter)
{
if (hours[index]>40)
{
OTpay = (hours[index] - 40)*1.5*payrate[index];
grosspay[index] = OTpay + (hours[index] * payrate[index]);
netpay[index] = grosspay[index] - (grosspay[index]*.03625);
}
else
{
grosspay[index] = hours[index] * payrate[index];
netpay[index] = grosspay[index] - (grosspay[index] * .03625);
}
index++;
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////end function 2
//
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////start function 3
void outputPayReport(string names[], float hours[], float payrate[], float grosspay[], float netpay[], int numOfEmps, int counter)
{
int index = 0;
cout << "______________________ your payroll sheet _______________________" << endl;
while (index < counter)
{
cout << names[index] << " " << payrate[index] << " " << hours[index] << " " << grosspay[index] << " " << netpay[index] << endl;
index ++;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////end function 3
|