Hi all I had made a post a bit ago and had a few responces, they all really helped and I got past that part so wanted to just finish up and needed a bit more assistance

so far I have everything i need outputing to the window with cout<< but it has to be sent to a file then from the file we need it to come back to the window.

it should read

Employee Name
Gross Pay ............... $ amount
Federal Tax ............. $ amount
State Tax ................ $ amount
Social Tax ...............$ amount
Medicare .................$ amount
Pension ...................$ amount
Health Insurance......$ amount
Net Pay ..................$ amount

I tried changing all the cout<< to send it to the file but I'm not sure what is wrong. also I am not sure how to get the money sign in front of the amount.

So far I have:

string employeefirst, employeelast;
double gross;
double federal, state, ss, med, pension, health, net;

cout << "What is the Employees Name " << endl;
cin >> employeefirst >> employeelast;
cout << "What is the Employees Gross Pay " << endl;
cin >> gross;

cout << fixed << showpoint << setprecision (2);
cout << setfill ('.');

ifstream indata;
ofstream outdata;
indata.open ("PayrollTaxes");
federal = (gross * .15);
indata >> left >> setw (22) >> "Federal Tax " >> right >> setw(14) >> federal >> endl;
state = (gross * .035);
indata >> left >> setw(22) >> "State Tax " >> right >> setw(14) >> state >> endl;
ss = (gross * .0575);
indata >> left >> setw(22) >> "Social Security Tax " >> right >> setw(14) >> ss >> endl;
med = (gross * .0275);
indata >> left >> setw(22) >> "Medicare/Medicaid Tax " >> right >> setw(14) >> med >> endl;
pension = (gross * .05);
indata >> left >> setw(22) >> "Pension Plan " >> right >> setw(14) >> pension >> endl;
health = 75.00;
indata >> left >> setw(22) >> "Health Insurance " >> right >> setw(14) >> health >> endl;
net = (gross - (federal + state + ss + med + pension + health));
indata >> left >> setw(22) >> "Net Pay " >> right >> setw(14) >> net >> endl;

getline (fout, 100);


Any help would be greatly appreciated. I really need to figure this file stuff out.


Thanks so much in advanced

Recommended Answers

All 2 Replies

Member Avatar for iamthwee

Well have you looked at the tutorials about writing to a file?

If you want to save to a file why are you using an input file ifstream? All you need is the output file ofstream, something like this:

ofstream outdata("PayrollTaxes.txt");
<snip>
outdata << left << setw (22) << "Federal Tax " << right << setw(14) << federal << "\n";

>>also I am not sure how to get the money sign in front of the amount.

Easy -- just Shift+4 key on an American keyboard. If you have a UK keyboard them you would probably want to use the pound key (I don't have that key on my keyboard)

outdata << ".... $" << amount.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.