PROGRAM CREATING PAYCHECK

IM HAVING ISSUES GETTING A PROGRAM TO READ INFO FROM A FILE AND DOING THE FINAL OUTPUT. CAN SOMEONE HELP ME PLEASE...





//////////////////////////////////////////////////////////////////////////
// Get // Post: if employee number in filename is valid returns SUCCESS
// Employee // and employeeName, payRate and ytdGross
// FileData // else returns INVALID_FILE
// // and employeeName, payRate and ytdGross are undefinded
////////////// if file does not exist return FILE_NOT_FOUND
int GetEmployeeFileData( char filename[], char employeeNumber[],
char employeeName[], double& payRate, double& ytdGross )
{
// Read the data from the employee file and confirm that empFileNumber in
// the opened file is the same as the employeeNumber received from the user
char empFileNumber[32];
ifstream fin( filename );
if ( !fin ) {
return FILE_NOT_FOUND;
}//endif
fin >> empFileNumber;
if ( strcmp( employeeNumber, empFileNumber ) ) {
return INVALID_FILE;
}//endif
fin.ignore( 1 );
fin.getline( employeeName, ARRAY_MAX, '\t' );
fin >> payRate >> ytdGross;

// Use show to confirm that data was read from the employee file correctly
show( empFileNumber );
show( employeeName );
show( payRate );
show( ytdGross );
getch();
return false;
}//endfn GetEmployeeFileData

///////////////////////////////////////////////////////////////////////////
// // Post: if employee number in filename is valid
// GetHoursFileData // returns SUCCESS and number of hoursWorked
// // else returns INVALID_FILE and hoursWorked is undefined
////////////////////// if file does not exist returns FILE_NOT_FOUND
int GetHoursFileData( char filename[], char employeeNumber[], double& hoursWorked )
{
// Read the data from the hours file and confirm that hrsFileNumber in
// the opened file is the same as the employeeNumber received from the user
char hrsFileNumber[32];
ifstream fin( filenumber );
if ( !fin ) {
cerr << "File " << filenumber << " not found!";
getch();
return 1;
}//endif

// Use show to confirm that data was read from the hours file correctly
show( hrsFileNumber );
show( hoursWorked );
return false;
}//endfn GetHoursFileData

///////////////////////////////////////////////////////////////////////////
// // Pre: none
// BuildFilename //
// // Post: filename contains extension concatinated to empNumber
///////////////////
void BuildFilename( char filename[], char empNumber[], char extension[] )
{
strcpy( filename, empNumber );
strcat( filename, extension );
}//endfn BuildFilename

///////////////////////////////////////////////////////////////////////////
// // Pre: none
// GrossPay //
// // Post: return gross pay
//////////////
double GrossPay( double payRate, double hoursWorked )
{
double pay;
if ( hoursWorked > 48.0 ) {
pay = pay + 1;
}else{
}//endif
return pay;
}//endfn GrossPay

///////////////////////////////////////////////////////////////////////////
// // Pre: none
// FederalTax //
// // Post: returns amount of federal taxes
////////////////
double FederalTax( double grossPay )
{
return 0.0;
}//endfn FederalTax
///////////////////////////////////////////////////////////////////////////
// // Pre: none
// StateTax //
// // Post: returns amount of state taxes
//////////////
double StateTax( double grossPay )
{
return 0.0;
}//endfn StateTax
///////////////////////////////////////////////////////////////////////////
// // Pre: none
// FICA //
// // Post: returns amount of fica taxes
//////////
double FICA( double grossPay )
{
return 0.0;
}//endfn FICATax
Last edited on
Topic archived. No new replies allowed.