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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 20:00
What statement best describes operating systems? it’s possible for modern computers to function without operating systems. most operating systems are free or very inexpensive. operating systems are managed by the computer’s microprocessor (cpu). operating systems manage the computer’s random access memory (ram).
Answers: 1
question
Computers and Technology, 22.06.2019 21:50
Given int variables k and total that have already been declared, use a while loop to compute the sum of the squares of the first 50 counting numbers, and store this value in total. thus your code should put 11 + 22 + 33 + + 4949 + 50*50 into total. use no variables other than k and total.
Answers: 2
question
Computers and Technology, 23.06.2019 23:30
What can you prevent issues related to downloading content form the internet
Answers: 1
question
Computers and Technology, 24.06.2019 17:30
List at least one thing to check for when you're checking the clarity and professionalism of a document.
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
question
English, 10.03.2021 01:50
Questions on the website: 13722367