Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Description For this assignment, you will use C++ filestreams to read from a file which will contain ticket prices and amount sold and output the

image text in transcribed

image text in transcribed

Description For this assignment, you will use C++ filestreams to read from a file which will contain ticket prices and amount sold and output the results to an output file. The input file that is given will contain two integers on each line separated with a blank space and the line will be terminated with an end of line character However, there could be negative values and/or non digit characters on each line in which your program needs to handle those situations. The next section will go over the details of the program Implementation details In the program you will need to create a function int read istream& in which takes in the input file stream variable and will return an integer read from the line, it will perform the following Create a string variable Read in a string (this could be a number string or a non number string Convert the string into a number using atoi function, so if you have a string called input, then atoi (input.c-strC)) will return the integer of that string, if this is not an integer, it will simply return a 0 Return the integer using the atoi function, if the atoi function returns a negative value, you will return a 0 So if this function returns a 0, then from main you can determine that there was some kind of input failure Using this function, your main will perform the following Prompt the user for an input file name 1. 2. Prompt the user for an output file name 3. open the input and output filestreams 4. If the input file from step 1 does not exist, out the error and terminate the program 5. Call the read function and store the result into a price variable 6. If at the end of the file go to step 7. Call the read function and store the result i a amount sold variable

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

More Books

Students also viewed these Databases questions

Question

=+2 How can the effectiveness of global virtual teams be improved?

Answered: 1 week ago

Question

=+1 What are the major issues related to international T&D?

Answered: 1 week ago