Infile/Outfile problems

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

using namespace std;

int main()
{
fstream infile;
ofstream outfile;
string firstName, lastName;
double annualSalary, grossPay, federalTax, socialSecurity, medicare, netPay;
int i;

infile.open("employees.txt");
outfile.open("employeesout.txt");

cout << "Processing Data" << endl;
cout << fixed << showpoint << setprecision(2);

for(i=0; i<=5; ++i)
{
infile >> firstName, lastName, annualSalary;
outfile << "Employee :" << firstName << lastName;
outfile << endl;


infile >> grossPay;
outfile << "Gross monthly pay is :$ " << grossPay << endl;
outfile << "Social sercurity amount to be witheld is :$" << (grossPay * 4.2);
outfile << endl;
outfile << "Medicare amount to be witheld is :$" << (grossPay * 1.45);
outfile << endl;

socialSecurity = grossPay * 4.2;
medicare = grossPay * 1.45;

if(grossPay < 179)
outfile << "The amount of income tax witheld is $0" << endl;

else if(grossPay >= 179 && grossPay >=904)
{
outfile << "The amount of income tax witheld is :$ " << 0.1 * grossPay << endl;
outfile << "Your net income pay will be :$ ";
outfile << grossPay -(socialSecurity + medicare + 0.1 * grossPay);
outfile << endl;
}

else if(grossPay >= 904 && grossPay >=3125)
{
outfile << "The amount of income tax witheld is :$ " << 72.50 + (.15 * grossPay) << endl;
outfile << "Your net income pay will be :$ ";
outfile << grossPay -(socialSecurity + medicare + .1 * grossPay);
outfile << endl;
}

else if(grossPay >= 3125 && grossPay >=7317)
{
outfile << "The amount of income tax witheld is :$ " << 405.65 + (.25 * grossPay) << endl;
outfile << "Your net income pay will be :$ ";
outfile << grossPay -(socialSecurity + medicare + 405.65 +.25 * grossPay);
outfile << endl;
}

else if(grossPay >= 7317 && grossPay >=15067)
{
outfile << "The amount of income tax witheld is :$ " << 1453.65 + (.28 * grossPay) << endl;
outfile << "Your net income pay will be :$ ";
outfile << grossPay -(socialSecurity + medicare + 1453.65 +.28 * grossPay);
outfile << endl;
}

else if(grossPay >= 15067 && grossPay >=32542)
{
outfile << "The amount of income tax witheld is :$ " << 3623.65 + (.33 * grossPay) << endl;
outfile << "Your net income pay will be :$ ";
outfile << grossPay -(socialSecurity + medicare + 3623.65 +.33 * grossPay);
outfile << endl;
}

else if(grossPay <= 32542)
{
outfile << "The amount of income tax witheld is :$ " << 9390.40 + (.35 * grossPay);
outfile << "Your net income pay will be :$ ";
outfile << grossPay -(socialSecurity + medicare + 9390.40 +.35 * grossPay);
outfile << endl;
}

else
outfile << "Invalid Input" << endl;
}
system("pause");

return 0;
}

Im having an issue where the text file outputs are not showing up, and when they do they are not accurate. The numbers for grossPay are reading in inaccuratly and the lines saying "Your net income will be" are not showing up in the text file. Maybe someone can see the errors im not picking up on. Thanks



Last edited on
Topic archived. No new replies allowed.