Payroll program with functions

Hi all,
I am currently taking my first course in C++, I enjoy the course but do find it difficult at times. I am currently having a problem with this current payroll program using functions. Everything looks good to me, but the output is the header info only. I was hoping someone else's eyes could pick up what I am missing... Any help, tips, ect... would be very much appreciated. Thanks!

The program:


#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;

int readalldata( char[ ], char[ ], char[ ], long int[ ], int[ ], float[ ], const int );
void findovertimehours( int[ ], int[ ], int );
void findovertimepay( int[ ], float[ ], float[ ], int );
void findregularhours( int[ ], int[ ], int );
void findregularpay( int[ ], float[ ], float[ ], int );
void findgrosspay( float[ ], float[ ], float[ ], int );
void findtaxrate( float[ ], float[ ], int );
void findtaxamount( float[ ], float[ ], float[ ], int );
void findnetpay( float[ ], float[ ], float[ ], int );
void printalldata( char[ ], char[ ], char[ ], long int[ ], int[ ], float[ ], int [ ], float[ ], float[ ], float[ ], float[ ], float[ ], int );

int main( ){
const int MAXSIZE = 100; // for maximum of 100 employees

//declaration of variables
int n;
long int empid[ MAXSIZE ];
char fname[ MAXSIZE ], lname[ MAXSIZE ], ms[ MAXSIZE ];
int hoursworked[ MAXSIZE ], overtimehours[ MAXSIZE ];
int regularhours[ MAXSIZE ];
float hourlyrate[ MAXSIZE ], regularpay[ MAXSIZE ];
float overtimepay[ MAXSIZE ], grosspay[ MAXSIZE ];
float taxrate[ MAXSIZE ], taxamount[ MAXSIZE ],netpay[ MAXSIZE] ;

//functions calls
n = readalldata( fname, lname, ms, empid, hoursworked, hourlyrate, MAXSIZE ); // get all data
findovertimehours( hoursworked, overtimehours, n );
findovertimepay( overtimehours, hourlyrate, overtimepay, n );
findregularhours( hoursworked, regularhours, n );
findregularpay( regularhours, regularpay, hourlyrate, n );
findgrosspay( regularpay, overtimepay, grosspay, n );
findtaxrate( grosspay, taxrate, n );
findtaxamount( grosspay, taxamount, taxrate, n );
findnetpay( grosspay, netpay, taxamount, n );
printalldata( fname, lname, ms, empid, hoursworked, hourlyrate, overtimehours, overtimepay, regularpay, grosspay, taxamount, netpay, n );

}//MAIN

int readalldata( char fname[ ], char lname[ ], char ms[ ],long int empid[ ], int hoursworked[ ], float hourlyrate[ ], int n ){
ifstream fin( "employee.txt" );
n = 0;

if(!fin) cout << "bad!" << endl;

while( fin >> fname[ n ] >> lname[ n ] >> ms[ n ]>>empid[ n ] >> hoursworked[ n ] >> hourlyrate[ n ] ) n++;

fin.close( );
return n;
}//READALLDATA

void findovertimehours( int hoursworked[ ], int overtimehours[ ], int n ){
for( int i = 0 ; i < n ; i++){
if( hoursworked[ i ] > 40 ) overtimehours[ i ] = hoursworked[ i ] - 40;
else overtimehours[ i ] = 0;
}//FOR
}//FINDOVERTIMEHOURS

void findovertimepay( int overtimehours[ ], float hourlyrate[ ],
float overtimepay[ ], int n ){
for( int i = 0 ; i < n ; i++){
overtimepay[ i ] = overtimehours[ i ] * hourlyrate[ i ] * 1.5;
}//FOR
}//FINDOVERTIMEPAY

void findregularhours( int hoursworked[ ], int regularhours[ ], int n ){
for( int i = 0 ; i < n ; i++){
if( hoursworked[ i ] > 40 ) regularhours[ i ] = 40;
else regularhours[ i ] = hoursworked[ i ];
}//FOR
}//FINDREGULARHOURS

void findregularpay( int regularhours[ ], float regularpay[ ],
float hourlyrate[ ], int n ){
for( int i = 0 ; i < n ; i++ ){
regularpay[ i ] = regularhours[ i ] * hourlyrate[ i ];
}//FOR
}//FINDREGULARPAY

void findgrosspay( float regularpay[ ], float overtimepay[ ],
float grosspay[ ],int n ){
for( int i = 0 ; i < n ; i++){
grosspay[ i ] = regularpay[ i ] + overtimepay[ i ];
}//FOR
}//FINDGROSSPAY

void findtaxrate( float grosspay[ ], float taxrate[ ], int n ){
for( int i = 0 ; i < n ; i++){
if( grosspay[ i ] > 500.00 ) taxrate[ i ] = 0.30;
else if(grosspay[ i ] > 200.00 ) taxrate[ i ] = 0.20;
else taxrate[ i ] = 0.10;
}//FOR
}//FINDTAXRATE

void findtaxamount( float grosspay[ ], float taxamount[ ],
float taxrate[ ], int n ){
for( int i = 0 ; i < n ; i++){
taxamount[ i ] = grosspay[ i ] * taxrate[ i ];
}//FOR
}//FINDTAXAMOUNT

void findnetpay( float grosspay[ ], float netpay[ ], float taxamount[ ], int n){
for( int i = 0 ; i < n ; i++){
netpay[ i ] = grosspay[ i ] - taxamount[ i ];
}//FOR
}//FINDNETPAY

void printalldata( char fname[], char lname[], char ms[],long int empid[], int hoursworked[], float hourlyrate[],
int overtimehours[], float overtimepay[], float regularpay[], float grosspay[],
float taxamount[], float netpay[], int n ){

cout <<setw(50) << "DR. EBRAHIMI'S PAYROLL INSTITUTE" <<endl;
cout<<setw(14)<<"First Name"<<setw(14)<<"Last Name"<<setw(8) <<"MS" <<setw(17)
<<"Employee ID" <<setw(4)<<"HW"<<setw(6)<<"HR"<<setw(8)<<"OTH"<<setw(8)<<"OTP"<<setw(9)<<"REGPAY"
<<setw(10)<<"GROSS"<<setw(8)<<"TAX"<<setw(12)<<"NET PAY"<<endl;

for( int i = 0 ; i < n; i++){
cout<<setw(14)<<fname[i]<<setw(12)<<lname[i]<<setw(9)<<ms[i]<<setw(13)<<empid[i]<<setw(9)
<<hoursworked[i]<<setw(6)<<hourlyrate[i]<<setw(8)<<overtimehours[i]<<setw(8)<<overtimepay[i]
<<setw(8)<<regularpay[i]<<setw(10)<<grosspay[i]<<setw(10)<<taxamount[i]<<setw(10)<<netpay[i]<<endl;
}//FOR
}//PRINTALLDATA
// end source code

The output I receive is:

DR. EBRAHIMI'S PAYROLL INSTITUTE
First Name Last Name MS Employee ID HW HR OTH OTP REGPAY GROSS TAX NET PAY

I am using Xcode 3.2.4 on a MacBook Pro. I receive no errors, its as if it is opening the text file but not passing the info to the functions. I'm stuck and not sure where to look. Thanks again.

[code] "Put your code inside code tags" [/code]
I guess the problem is with read_all_data, returning 0 as number of values read.
Topic archived. No new replies allowed.