Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The manager of a football stadium wants you to write a program that calculates t

ID: 670755 • Letter: T

Question

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 Sample data are shown below: The first line indicates that the ticket price is $250 and that 5750 tickets were sold at that price. Output the number of tickets sold and the total sale amount. Format your output with two decimal places.

Explanation / Answer

#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;

int main() {
   double total=0;
   int nTickets=0;
   std::ifstream infile("tickets.txt");
   int a, b;
while (infile >> a >> b)
{
total=a*b;
nTickets=nTickets+b;
}
cout<<"Total Sale amount: "<<total<<endl;
cout<<"Number of tickets sold: "<<setprecision (2)<<nTickets<<endl;
   return 0;
}