In my assignment, I am supposed to create an input file and then read it into a c++ program. The following is what I have so far and at the end is the file I created. Can anyone tell me if I am on the right track?
CODE
#include <fstream>
#include <iostream>
using namespace std;
int main()
{ string name;
int number, begBalance, ccCharges, paid, finCharges, curBalance, num_cust, sum;
ifstream infile;
ofstream outfile;
infile.open("customer.dat");
assert(!infile.fail());
outfile.open("summary.dat");
infile >> name;
while (! infile.eof())
{
infile >> number >> name >> begBalance >> ccCharges >> paid >> finCharges;
curBalance = (begBalance+(ccCharges-paid)+finCharges);
cout << number << endl;
outfile << number << endl;
infile >> name;
}
infile.close();
outfile.close();
}
customer.dat
1000 West 5150.50 375.75 85.15 12.18
2000 Cummins 7505.80 718.15 70.87 15.15
3000 Matson 3643.75 600.00 93.54 9.85
4000 Sutton 1587.50 954.23 105.78 26.97
5000 Orr 4578.65 397.85 85.00 19.17