Ok so I need to pull up records one at a time and then have the loop terminate when it reches the end of the input file using while and the istreamVar.eof() commands
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
int main()
{
ifstream ticketSale;
int num2, num4, num6, num8;
double num1, num3, num5, num7;
while(!ticketSale.eof())
ticketSale.open("c:\\ticketSale.txt");
cout << fixed << showpoint;
cout << setprecision(2) << endl;
ticketSale >> num1 >> num2;
cout << "Ticket Price: $ " << num1 << " Tickets Sold: " << num2 << " Profit: $ " << num1*num2 << endl;
ticketSale >> num3 >> num4;
cout << "Ticket Price: $ " << num3 << " Tickets Sold: " << num4 << " Profit: $ " << num3*num4 << endl;
ticketSale >> num5 >> num6;
cout << "Ticket Price: $ " << num5 << " Tickets Sold: " << num6 << " Profit: $ " << num5*num6 << endl;
ticketSale >> num7 >> num8;
cout << "Ticket Price: $ " << num7 << " Tickets Sold: " << num8 << " Profit: $ " << num7*num8 << endl;
ticketSale.close();
return 0;
}
Input file contains:
250 5750
100 28000
50 35750
25 18750
Actual problem reads:
//Use the infile statement, while statement, and infile.eof() statement
//to try to read one record a time, process them and then read another
//record until end of file.
Please help ^^;