Difficulty with input/output streams 
Author Message
 Difficulty with input/output streams

The class is Employees--there are 3 instances of that class
I have an array of 53 items (to actually reference 52) containing weekly hours,
gross, tax and net.  Switch case 6 is supposed to add all of the 52 elements in
each array of hours, gross, tax and net, display the results and store them to
a file.  The file, when viewed shows 2 records with all the weekly results
stored properly, but no end of year totals.  The third record contains the
name, ss#, etc., AND  the yearly totals in bizarre notation in random
locations.    
In addition to this, I can't open the file to add more weeks' hours, etc.
Please, if anyone can help, I would be eternally grateful!!!!

case 6:
output.open("Employees.dat", ios::app);
cout << "BOB'S CAR WASH" << endl;
cout << "END OF YEAR WAGE REPORT" << endl;
cout << " " << endl;
cout << setw(108) << " " << "________________________________________________"
<< endl;
cout << " " << endl;
cout << setw(108) << " " << "Gross Income      Taxes Withheld     Net Income "
<< endl;
cout << setw(108) << " " << "________________________________________________"
<< endl;
for (i =0; i < 3; i++)
              {                        
              Employees[i].CalcAll();
        output << Employees[i].GetGrossToDate() << '\n';
        output << Employees[i].GetTaxToDate() << '\n';
        output << Employees[i].GetNetToDate() << '\n';
        Employees[i].PrintEndOfYearReport();
        }
output.close();
break;
case 7:
input.open("Employees.dat", ios::in);
for (i = 0; i < 3; i++)
        {
        input.get(tempLast, 39);
        Employees[i].InEmpLast(tempLast);
        cout << tempLast << '\n';
        input.get(ch);          
        input.get(tempFirst, 39);
        Employees[i].InEmpFirst(tempFirst);
        cout << tempFirst << '\n';
        input.get(ch);
        input.get(tempSocial, 14);
        Employees[i].InEmpSocial(tempSocial);
        cout << tempSocial << '\n';
        input.get(ch);
        input >> tempPayRate;
        Employees[i].InEmpPayRate(tempPayRate);
        cout << tempPayRate << '\n';
        input.get(ch);
        input >> tempTaxRate;
        Employees[i].InEmpTaxRate(tempTaxRate);
        cout << tempTaxRate << '\n';
        input.get(ch);
        for (w = 0; w < 53; w++)
                {
                input >> tempWeeklyHours;
                cout  << tempWeeklyHours << '\n';
                input.get(ch);
                Employees[i].InWeekHours(w, tempWeeklyHours);
                input >> tempGross;
                cout  << tempGross << '\n';
                input.get(ch);
                Employees[i].InGross(w, tempGross);
                input >> tempTax;
                cout  << tempTax << '\n';
                input.get(ch);
                Employees[i].InTax(w, tempTax);
                input >> tempNet;
                cout  << tempNet << '\n';
                input.get(ch);
                Employees[i].InNet(w, tempNet);
                }
                for(i = 0; i < 3; i++)
                        {
                        input >> tempGrossToDate;
                        cout  << tempGrossToDate << '\n';
                        input.get(ch);
                        Employees[i].InGrossToDate(tempGrossToDate);
                        input >> tempTaxToDate;
                        cout  << tempTaxToDate << '\n';
                        input.get(ch);
                        Employees[i].InTaxToDate(tempTaxToDate);
                        input >> tempNetToDate;
                        cout  << tempNetToDate << '\n';
                        input.get(ch);
                        Employees[i].InNetToDate(tempNetToDate);
                        }
                        }
input.close();
break;



Sat, 23 Sep 2000 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Unable to sync input and output streams

2. Programming REXEC() with input and output streams

3. Can't sync input and output streams...

4. input, output, input/output parameters?????

5. How to clear input stream in ANSI C?

6. c file (stream) input buffer problem help PLEASE!

7. flushing the standard input stream (newb question)

8. ANN: Numeric input from file streams

9. clearing input streams

10. state of input stream after bad scanf ?5

11. problem with standard error/output streams

12. Problem with input stream redirection in lex

 

 
Powered by phpBB® Forum Software