hi guys im new to c++ can i have some assist ?
The manager of a football stadium wants you to write a program that calculates the total ticket sales after each game. There are four types of tickets box, sideline, premium, and general admission. After each game, data is stored in a file in the following form:
ticketPrice numberOfTicketsSold
250 5750
100 28000
50 35750
25 18750
output the number of tickets sold and the total sale amount. Format your output with two decimal places.
my current file for SampleData.txt
250 5750
100 28000
50 35750
25 18750
my file for ReformatData.dat
Number of tickets sold = 0
Sale amount = $0
Now i couldnt get the numbers of tickets sold and sale amount. may i have some assist on where should i change ? thanks in advanced!
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
int main()
{
double tPrice;
int numOfTicketsSold=0;
int ticketsSold;
double totalSale=0;
ifstream inFile;
ofstream outFile;
inFile.open("SampleData.txt");
outFile.open("ReformatData.dat");
outFile << fixed << showpoint << setprecision(2);
cout << "wait " << endl;
for (int i=0; i<4; i++)
{
inFile >> tPrice >> ticketsSold;
totalSale=tPrice*ticketsSold;
numOfTicketsSold=numOfTicketsSold+ticketsSold;
}
outFile << "Number of tickets sold = " << numOfTicketsSold << endl;
outFile << "Sale amount = $" << totalSale << endl;
inFile.close();
outFile.close();
return 0;
}