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: 3854203 • 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 flat file in the following form:

ticketPrice numberOfTicketsSold

Sample data are shown below:
250 5750
100 28000
50 35750
25 18750

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.

To solve this problem, you must create the input data file manually. To do this in CodeBlocks, go to the File menu and select New and then Empty File. A popup will ask if you want to add this file to the project. When you say yes, you will have to name the file. It is best to put a .txt extension on the file name. This type of file is called a flat file. A flat file is similar to a spread sheet in that all the fields (columns) contain the same type of information and the records (rows) contain different data values.

Turn in: structure chart, source code and output showing test results (screen shot or picture)

Checklist:

Structure chart included

File name included as comment at top of source file

IPO chart included as comments following the file name

Variable names are meaningful

Program compiles

Program produces correct results

Program is thoroughly tested with test output included

Explanation / Answer

#include <iostream>

#include <fstream>

#include <iomanip>

using namespace std;

int main()

{

ifstream inFile;

int ticketPrice;

int noOfTicketSold;

inFile.open("c:\Dev-Cpp\inFile.txt");

cout << fixed << showpoint;

cout << setprecision(2);

cout << "Processing data" << endl;

while( inFile >> ticketPrice >> noOfTicketSold);

{

cout << "Number of tickets sold : " << noOfTicketSold << endl;

cout << "Total sale ammount : " << ticketPrice * noOfTicketSold << endl;}

inFile.close();

return 0;

}