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 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
#include <fstream>
#include <iomanip>
#include <iostream>
using namespace std;
float findsum(float net, float sum, int);
float findaverage(float average, float sum, int);
int main(int argc, char *argv[]){
char stat[100];
char fn[100][14], ln[100][15];
int ssn[100], hw[100], hr[100];
float oth[100], otp[100], regp[100], gross[100], taxamnt[100];
float taxrate[100];
float net;
float sum; //Is the problem here? the error says 'declaration of 'float sum' shadows a parameter', but that is the code my Instructor suggested.
float average; //Or here?
int i;
int n;
cout<<"__________________________________________________________________________"<<endl;
cout<<"DR. EBRAHIMI'S PAYROLL INSTITUTE"<<endl;
cout<<"=========================================================================="<<endl;
ifstream fin("employeeM4.txt");
cout<<setw(2)<<"FIRST"<<setw(8)<<"LAST"<<setw(8)<<"STAT"<<setw(5)<<"SSN"<<setw(5)<<"HW"<<setw(4)<<"HR"<<setw(4)<<"OTH"
<<setw(5)<<"OTP"<<setw(5)<<"REGP"<<setw(6)<<"GROSS"<<setw(6)<<"TAX"<<setw(6)<<"NET"<<endl;
cout<<"=========================================================================="<<endl;
while(fin>>fn[i]>>ln[i]>>stat[i]>>ssn[i]>>hw[i]>>hr[i]){
if(hw[i]>40){
oth[i]=hw[i]-40;
otp[i]=oth[i]*hr[i]*1.5;
regp[i]=40*hr[i];
}
else{
oth[i]=0;
otp[i]=0;
regp[i]=hw[i]*hr[i];
}
gross[i] = regp[i]+otp[i];
if(gross[i]>1000) taxrate[i] = .30;
else if(gross[i]>800) taxrate[i] = .20;
else if(gross[i]>500) taxrate[i] = .10;
else taxrate[i] = 0;
//if(stat[i]==S) taxrate[i] = taxrate[i]+.05;
//else if(stat[i]==H) taxrate[i] = taxrate[i]-.05;
//else if(stat[i]==M) taxrate[i] = taxrate[i]+0;
taxamnt[i] = gross[i]*taxrate[i];
net = gross[i]-taxamnt[i];
cout<<fn[i]<<setw(10)<<ln[i]<<setw(5)<<stat[i]<<setw(7)<<ssn[i]<<setw(5)<<hw[i]<<setw(4)<<hr[i]<<setw(4)<<oth[i]<<setw(4)
<<otp[i]<<setw(5)<<regp[i]<<setw(6)<<gross[i]<<setw(6)<<taxamnt[i]<<setw(6)<<setprecision( 4 )<<net<<endl<<endl;
i++;
}//WHILE
n=i;
sum = findsum(net, sum, n);
average = findaverage(average, sum, n);
cout<<endl<<"The sum of the Employees' Netpay is: "<<sum<<endl<<endl;
cout<<"The average Employee Netpay is: "<<average<<endl;
cin.get();
return 0;
system("PAUSE");
return EXIT_SUCCESS;
}//MAIN
float findsum(float net[], float sum[], int n){
float sum=0.0; //It says this is shadowing a parameter
for(int i=0;i<n;i++){
sum=sum+net[i];
}//FOR
return sum;
}//FINDSUM
float findaverage(float average[], float sum[], int n){
float average; //It says this is shadowing a parameter as well
average=sum/n; //|119|error: invalid operands of types `float*' and `int' to binary `operator/'| I am not sure what this means
return average;
}//FINDAVERAGE
|