Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am only having issues with my set precision. How do I get the output file to only go to 2 decimals ? Review the

I am only having issues with my set precision. How do I get the output file to only go to 2 decimals ?

  1. Review the General Programming Assignment instructions.
  2. 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 ticketsbox, 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.)

***********READ********

I am only having issues with my set precision. How do I get the output file to only go to 2 decimals ?image text in transcribed

#include #include #include using namespace std; int main() { //This is where we declare variables double total = 0; int nTickets = 0; ifstream infile("Ch3_Ex5Data.txt"); ofstream outfile("Ch3_Ex50ut.txt"); int a, b; while (infile >> a >> b) total += a *b; nTickets = nTickets + b; outfile

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions

Question

4. Explain the strengths and weaknesses of each approach.

Answered: 1 week ago