Help on program

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

using namespace std;

int main()
{
ifstream infile;
ofstream outfile;
string firstname, lastname;
float currentsalary;
float payincrease;

infile.open("lab4Data.txt");
outfile.open("lab4Result.txt");

infile >> lastname;
infile >> firstname;
infile >> currentsalary;
infile >> payincrease;

while (infile)
{
outfile << lastname << firstname<< (currentsalary + 0.5f) + ( (currentsalary+ 0.5f) * (payincrease / 100));
infile >> lastname >> firstname >> currentsalary >> payincrease;
}

infile.close();

outfile.close();

system("pause");

return 0;
}

lab4Data = Miller Andrew 65789.87 5
Green Sheila 75892.56 6
Sethi Amit 74900.50 6.1

I am trying to take data from a file, calculate it, and put it into another file, but somehow the program is reading the inputfile but not putting it into the outputfile.
Is there something wrong with the loop?
I think you might want to read the data in from infile before you try to write it to outfile.
i wrote
infile >> lastname >> firstname >> currentsalary >> payincrease;
between
infile >> payincrease;
and
while (infile)
but it is still not sending information to the ourfile.
Topic archived. No new replies allowed.