So I've missed the past week of my C++ class due to the SEC swimming championships being a week long :@, and I've missed the whole topic on file processing. I've been reading the slides and a few tutorials via lovely google searching, but it's a little hazy. Can anyone pleasee point me in the direction of where to go (some hints etc) or a tutorial that will fit to help me in what I need to accomplish this next project:
(A little background, I wrote a code for last weeks project that will accept the degree of a polynomial and the coefficients as coef[], and from there the program can print the polynomial or integrate it over a given interval)
Batch Polynomial Handling
By selecting option 4 on the main menu, the user will be able to specify the names of an input file
and an output file. The program will then read coefficient-boundary pairs from the input file and,
for each pair, print both the formatted polynomial and the average of that polynomial over the
interval specified. For example, consider the following input file:
1. 3 1.3 0.9 4.7 2 -5.4 5
2. 2 5 6.3 1 0.4 10.7
3. 1 1 0 -1 2
[Bold and underlines are added for clarification and are not in the input file.]
Each line of the input file describes one polynomial-boundary pair. The first integer (in bold here)
states the degree of that line’s polynomial. The next (degree + 1) numbers are the
coefficients of that polynomial, highest-order first, just as in the last few projects. The last two
numbers, underlined here, are the boundaries a and b over which you will evaluate the average of
that polynomial.
The output file will follow the same one-polynomial-per-line format, with this on each line:
Average of [polynomial], on [a,b] is [average]
Where [polynomial] is the input polynomial printed neatly as in project 4. For the input file
above, the following would be written to the output file:
Average of 1.3x^3+0.9x^2+4.7x+2, on [-5.4,5] is 2.1672
Average of 5x^2+6.3x+1, on [0.4,10.7] is 234.18167
Average of x, on [-1, 2] is 0.5
In keeping with the coding guidelines above, it is recommended that all of this functionality is
kept within the process(ifstream& in, ofstream& out) function.