I have a very basic question. Here is my code:
Code:
#include <iostream>
#include<fstream>
#include <iomanip>
using namespace std;
void main( )
{
ifstream inFile;
double ticketPrice;
double numSold;
double totalSale;
inFile.open("ticketSales.txt");
inFile >> ticketPrice >> numSold;
while (!inFile.eof())
{
totalSale = numSold * ticketPrice;
cout << fixed << showpoint << setprecision(2);
cout << "Total sale amount: $" << totalSale << endl;
}
}
So only the first line of the file is read and it just continues to show on the screen. It never reads the next line of the file. I have tried searching for help on FAQ's and haven't gotten help thus far. As far as I understand a counter wouldn't work because I don't know what the input file will actually have at all times. Here is an example of an input file:
250 5750
100 28000
50 35750
25 18750
Thank you for your help!!