Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

x.Hme one last programing assignment due this semester. It is dealing with funct

ID: 3615398 • Letter: X

Question

x.Hme one last programing assignment due this semester. It is dealing with functions, and there are a total of nine. I can only use the 'fstream' and 'iomanip' library. We are using 2D arrays. There is an input file with a list of "employee numbers", "hours worked" and "hourly wage" in the format of:
2145 40 10.25
2547 37 11.25
and so on...
The program is completly written but there is something going on with what I believe is the 'dataIn' function. The program is supposed to calculate the 'state tax', 'fed tax' 'overtime pay' 'gross pay' etc...
on the output file the first three columns are correct but there are garbage values for the rest of them. could someone please point me in the right direction...



#include <fstream>
#include <iomanip>

using namespace std;

const int ROWS = 10;
const int COLS = 7;

const double CUT_OFF = 40.00,
             STATE_TX_RATE = 0.06,
             TAX_CUT_OFF = 400.00,
             LOW_TAX_RATE = 0.20,
             HI_TAX_RATE = 0.31;

void printIdInfo ( ofstream &fout );
void printReportHeadings ( ofstream &fout );
void dataIn ( ifstream &fin, int [], double [][COLS] );
void overTime ( double [][COLS] );
void grossPay ( double [][COLS] );
void stateTax ( double [][COLS] );
void federalTax ( double [][COLS] );
void netPay ( double [][COLS] );
void printReportData ( ofstream &fout, int [], double [][COLS] );

int main( )
{  
   int employee[ROWS];
   double payroll[ROWS][COLS];
          
   ifstream fin;
   ofstream fout;

   fin.open("prog6_inp4.txt");
   fout.open("prog6_out4.txt");

   printIdInfo ( fout );
   printReportHeadings ( fout );
   dataIn ( fin, employee, payroll );
   overTime ( payroll );
   grossPay ( payroll );
   stateTax ( payroll );
   federalTax ( payroll );
   netPay ( payroll );
   printReportData ( fout, employee, payroll );

   fin.close();
   fout.close();

   return 0;
}

void printIdInfo ( ofstream &fout)
{
     fout << "Authors: "
          << " CS ."
          << " 12/03/2009 ";
}

void printReportHeadings ( ofstream &fout )
{
     fout << setw(49) << "Monthly Payroll Report" << endl << endl << " ID#"
          << setw(11)
          << "Hours" << setw(10) << "Hourly" << setw(12) << "Overtime"
          << setw(10) << "Gross" << setw(11) << "State" << setw(11) << "Federal"
          << setw(8) << "Net" << endl << setw(15) << "Worked" << setw(9)
          << "Rate" << setw(12) << "Hours" << setw(10) << "Pay" << setw(11)
          << "Tax" << setw(10) << "Tax" << setw(10) << "Pay" << endl;
          
}


void dataIn (ifstream &fin, int employee [], double payroll [][COLS])
{
        for (int row = 0; row < ROWS; ++row)
        {
            fin >> employee[row];
            for(int col = 0; col < 2; ++col)
            {
                    fin >> payroll[row][col];
            }
        }
}


void overTime(double payroll [ ][COLS])
{
    double hours_worked,
           overtime_hours;
  
    for (int row = 0; row < ROWS; ++row)
    {
        hours_worked = payroll[row][0];
       
        if ( hours_worked > CUT_OFF )
            payroll[row][2] = hours_worked - CUT_OFF;
        else
            payroll[row][2] = 0.0;     
     
    }  
}


void grossPay( double payroll[][COLS] )
{
     for ( int row = 0; row < ROWS; ++row)
     {
         if ( payroll[row][3] > 0 )
         {
             payroll[row][4] = (payroll[row][3] * (payroll[row][2] * 1.5)) +
             ( CUT_OFF * payroll[row][2]);
         }
         else
         {
             payroll[row][4] = (payroll[row][2] * payroll[row][1]);
         }
     }
}



void stateTax( double payroll [][COLS] )
{
     for( int row = 0; row < ROWS; ++row )
     {
          payroll[row][4] = ( payroll [row][3] * STATE_TX_RATE );   
     }    
}


void federalTax (double payroll[][COLS])
{
     for (int row = 0; row < ROWS; ++row)
     {
         if (payroll[row][3] <= TAX_CUT_OFF)
             payroll[row][5] = payroll[row][3] * LOW_TAX_RATE;
         else
         {
             payroll[row][5] = ((payr 2145 40 10.25
2547 37 11.25
and so on...

Explanation / Answer

x.