Need a nudge in the right direction

Im doing this assignment where i need to read in data that has hours worked, rate of pay, union member or not(0 or 1), and their ID with EOF. I am having some difficulty with the infile at the moment, also if you see problems please i appreciate any help.

ifstream infile;
ofstream outfile;

infile.open("fileIn.txt");
outfile.open("fileOut.txt");

double IDCode, hours, rate, pay, dues;
double unionDues, netPay;
int unionStatus;

while (!InFile.eof())
{
{
inFile >> IDCode >> hours >> rate >> unionStatus >> endl;
}

//overtime
if(hours > 40)
{
pay = (hours * rate) + ((hours-40) * 1.5 * rate);
}
//regular
else
{
pay = hours * rate;
}

//union
if(unionStatus==1)
{
unionDues= pay * .10;
}
else if(unionStatus==0)
{
unionDues= 5;
}
else
{
unionDues= 0;
}
netPay = pay - unionDues;
}

//outfile
outfile <<"WEEKLY PAYROLL"<< endl;
outfile << " " << endl;
outfile << "ID No. Hours Rate Pay Member Dues Net "<< endl;
outfile << IDCode << hours << rate << pay << unionStatus << dues << pay << endl;


outFile.close();
inFile.close();
return 0;
please use code format when poting. it is easier to read!
indents and all, correct?
[code]put your code here in between these[/code]

that will make your information readable as code here on the forums.
Im doing this assignment where i need to read in data that has hours worked, rate of pay, union member or not(0 or 1), and their ID with EOF. I am having some difficulty with the infile at the moment, also if you see problems please i appreciate any help.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
ifstream infile;
ofstream outfile;

infile.open("fileIn.txt");
outfile.open("fileOut.txt");

double IDCode, hours, rate, pay, dues;
double unionDues, netPay;
int unionStatus;

while (!InFile.eof())
{
{
inFile >> IDCode >> hours >> rate >> unionStatus >> endl;
}

//overtime
if(hours > 40)
{
pay = (hours * rate) + ((hours-40) * 1.5 * rate);
}
//regular 
else
{
pay = hours * rate;
}

//union 
if(unionStatus==1)
{
unionDues= pay * .10;
}
else if(unionStatus==0)
{
unionDues= 5;
}
else
{
unionDues= 0;
}
netPay = pay - unionDues;
}

//outfile 
outfile <<"WEEKLY PAYROLL"<< endl;
outfile << " " << endl;
outfile << "ID No. Hours Rate Pay Member Dues Net "<< endl;
outfile << IDCode << hours << rate << pay << unionStatus << dues << pay << endl;


outFile.close();
inFile.close();
return 0;

better?
closed account (2UD8vCM9)
Please post an example of a .txt you will be reading from
123 46 6.50 1
456 32.12 3 0

this is an example
i'm completely lost, my infile keeps coming up as an error when i'm matching both my previous programs that use it, and im using <fstream>. where am i going wrong?
Topic archived. No new replies allowed.