subject
Computers and Technology, 04.03.2020 06:04 fmw812

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:
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 total number of tickets sold and the total sale amount into an output file. Format your output with two decimal places. (You are required to generate an output file that has the results.)

So far my answer is

#include

#include

#include

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;

system("pause");

return 0;

}

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 22:30, ayoismeisjuam
What are compression artifacts? 1) visible defects in the picture caused by the nature of the compression algorithm. 2) numbers that tell a web server how much to compress a picture for faster transmission. 3) invisible defects in the picture preserved by lossless compression. 4) numbers that tell a photo editing program how much to compress a picture for faster transmission.
Answers: 3
image
Computers and Technology, 22.06.2019 08:00, luclaymom805
Aplan to budget time for studying and activities is referred to as a study routine. study habits. study skills. a study schedule.
Answers: 1
image
Computers and Technology, 23.06.2019 09:00, Riddledjam44623
Before you record your own voice, you should a. record other people's voices b. warm up and practice difficult names c. listen to your favorite songs d. read a transcript of a good radio news segment
Answers: 1
image
Computers and Technology, 23.06.2019 12:30, legend101xD
Animations and transitions are added from the
Answers: 1
You know the right answer?
The manager of a football stadium wants you to write a program that calculates the total ticket sale...

Questions in other subjects:

Konu
Spanish, 08.07.2021 20:40
Konu
Mathematics, 08.07.2021 20:40