I have the following program, but what do i need to change in order to get it to output to a file? any help would be greatly appreciated.
thanks

#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>


using namespace std;
string employeeFirst, employeeLast;
double gross;
double federal, state, ss, med, pension, health, net;


int main()
{

	cout << "what is the Employees First Name:" << endl;
cin >> employeeFirst;
cout << "what is the Employees Last Name:" << endl;
cin >> employeeLast;
cout << "What is the Employees Gross Pay:" << endl;
cin >> gross;

cout << fixed << showpoint << setprecision (2);
cout << setfill ('.');
cout << left << setw(33) <<"Gross Amount" << right << setw(0) << gross << endl;
 
federal = (gross * .15);
cout << left << setw(34) << "Federal Tax" << right << setw(0) << federal << endl;
state = (gross * .035);
cout << left << setw(34) << "State Tax" << right << setw(0) << state << endl;
ss = (gross * .0575);
cout << left << setw(34) << "Social Security Tax" << setw(0) << ss << endl;
med = (gross * .0275);
cout << left << setw(34) << "Medicair/Medicaid Tax" << setw(0) << med << endl;
pension = (gross * .05);
cout <<left << setw(34) << "Pension Plan" << setw(0) << pension << endl;
health = 75.00;
cout << left << setw(36) << "Health Insurance" << setw(0) << health << endl;
net = (gross-(federal + state + ss + med + pension + health));
cout << left << setw(33) << "Net Pay" << setw(0) << net << endl;


return 0;
}

pretty simple actually -- replace cout with an ofstream object. You have already included all the necessary header files so all you have to do is declare an ofstream object at the beginning of the program and use it instead of cout wherever you need to.

pretty simple actually -- replace cout with an ofstream object. You have already included all the necessary header files so all you have to do is declare an ofstream object at the beginning of the program and use it instead of cout wherever you need to.

thank you very much

This question has already been answered. Start a new discussion instead.