HELP WITH INPUT/OUTPUT FILE STREAMING

I'm trying to write a program that will read from a file a list of incomes for persons employed ( I have the input file already made ) and also read the data to a output file in a formatted order. I wrote this program but there were still errors that I don't really understand.

Help please ?







#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
using namespace std;
int main ()
{
string firstname, lastname;
float grossincome, FICA, SSTax, Taxamount;

ifstream infile;
infile.open("nc_incomes.txt");

cout << "Reading from file " << endl;
infile >> firstname >> lastname >> grossincome;

cout << firstname << lastname << grossincome;
infile.close();

ofstream outfile;
outfile.open(nc_netsalaries.dat");

cout << fixed << setprecision(2) << setw(20) << endl;

cout << "First Name" << "Last Name" << "Gross Income" << "FICA" << "SS-Tax" << endl;

cout << firstname << lastname << grossincome << endl;

FICA = grossincome * (0.18);

SSTax = grossincome * (0.7);

Taxamount = FICA - SSTax;

cout << firstname << lastname << grossincome << FICA << SSTax << Taxamount << endl;
outfile.close();

return 0 ;
}
Topic archived. No new replies allowed.