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
Which of these statements about digital media is NOT accurate?
DIA [1.3K]

Answer:

It is any information that is audio or video but not text.

Explanation:

5 0
2 years ago
What type of bus does PCI use?
Vera_Pavlovna [14]

Answer:

PCI uses a 32-bit or 64-bit parallel bus.

8 0
2 years ago
Question 1<br> a node is.<br> •a sever<br> A Cell Phone<br> A Laptop<br> a device on a network
RSB [31]

Answer:

From Networkopoint of view, a node is a redistribution point or communication point or a connection point.

It can also mean devices or data points on a large network Such as laptop, phones, printers, etc

Explanation:

3 0
4 years ago
What is the name of the mvost powerful battery
sergij07 [2.7K]
Optima battery because it is stronger than a factory battery
6 0
3 years ago
The process of providing only the essentials and hiding the details is known as _____. a. algorithm b. data structure c. abstrac
adoni [48]
The answer is (data) abstraction!
Hope it helped (:
3 0
3 years ago
Other questions:
  • Regulatory control limits the activities of an organization in compliance with the organization's policies. True False
    14·2 answers
  • 1. of the following individuals, who was the most recent to develop information searching tools online? (points : 1) otlet wells
    5·1 answer
  • Which social network site has 1.5 billion actives users per month?
    15·1 answer
  • What sugar is used in a DNA molecule​
    7·2 answers
  • The four key stages with regards to data visualization workflow. Select one key stage and explain it briefly about that stage.St
    10·1 answer
  • The right of workers to seek safety and health on the job without fear of punishment is spelled out in:
    8·1 answer
  • Consider the following classes: public class Vehicle {...} public class Car extends Vehicle {...} public class SUV extends Car {
    8·1 answer
  • Which of the following best describes professional behavior in the IT field?
    6·1 answer
  • Assert statements are a tool programmers employ to help them debug their code more efficiently.
    6·1 answer
  • Scenario: The deputy incident commander will be replacing the current incident commander, who needs to attend to a family emerge
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!