1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
lutik1710 [3]
3 years ago
6

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;

}
Computers and Technology
1 answer:
vazorg [7]3 years ago
4 0

<u>Answer:</u>

The following will be used:

#include <iostream>

#include <fstream>

#include <iomanip>

using namespace std;

int main() {

  double total = 0;

  int nTickets = 0;

  ifstream infile("tickets.txt");

  ofstream outfile("output.txt");

  int a,b;

  while (infile >> a >> b)

  {

      total += a*b;

      nTickets = nTickets + b;

  }

  outfile << "Total Sale amount: " << setprecision(2) << total << endl;

  outfile << "Number of tickets sold: " << nTickets << endl;

  outfile.close();

  cout<<"See output file: output.txt for the results."<<endl;

  return 0;

}

You might be interested in
An employee mentions that opening a large document file is taking longer than usual. The desktop support technician suspects tha
kumpel [21]

Answer:

Perform data backup on the work computer

Explanation:

It is very important that at every point in time that a technician will perform a maintenance, repair, or troubleshooting. the data on the work computer should be backed up to avoid loss. This is done to avoid data loss resulting from failure from hardware or software, backup provides copy of critical data immediately the maintenance is done, therefore backup is very important before any troubleshooting is done.

8 0
3 years ago
Help me plz What character must always be used when a formula is enter in a cell? (on a spreadsheet)​
lara [203]

Answer:

The equal sign "=" must be used.

Most, if not all, spreadsheet programs support formulas, but you must start them with an equal sign.

8 0
3 years ago
Why is it important not to leave your personal information on a public computer?
zheka24 [161]

Answer:

B. Someone can steal the information and hurt you.

Explanation:

People can hack into your accounts using your informations and spread hurtful things that can make people hurt. The people will think that you posted this (even if you didn't) and blame you.

7 0
2 years ago
Leslie Is doing a sociological study of people who have live remote island. She interviews the people and than she observes them
dimulka [17.4K]
Making guesses, as opposed to the other answers, this is the only one that forges new ideas and doing such will only lead to an illegitimate conclusion/study.
5 0
3 years ago
Read 2 more answers
Which of the following CANNOT be done in Normal view A. Enter bolded text in the Notes Pane B. Delete previously entered notes i
blondinia [14]

Answer:

<em>Well, Your answer will be is </em><em>B. Delete previously entered notes in the Notes Pane. Good Luck!</em>

3 0
3 years ago
Other questions:
  • Ryan wants to ensure that all the words in this document are evenly spaced so that they look neat and readable . Which option in
    12·1 answer
  • What port number is the well-known port used by web servers to distribute web pages to web browsers?question 3 options:?
    6·1 answer
  • What color does Sam obtain when he mixes white with a color? Sam is painting a landscape and needs to paint the sky light blue.
    9·2 answers
  • A user found that their personal data had been exfiltrated from their computer by a malicious program that they clicked on sever
    12·1 answer
  • When Hallmark designs its website so that a teenage girl can send a theme card to her boyfriend's cell phone, what is the primar
    6·1 answer
  • When your friend DaJuan turns on his computer, he hears four beeps. The computer won’t fully boot. DaJuan has a Dell computer wi
    7·1 answer
  • How does a author develop a character in a story?
    14·2 answers
  • Misspelet errors are displays with a ...<br>.. below them<br>​
    10·1 answer
  • Is e commerce a challenge or opportunity to the freight forwarder
    8·1 answer
  • Authenticating information can be something a user knows, like a password; something a user has, like a smart card; or something
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!