Lab 7 Part 1: File I/O
Due: Sun, Apr 8, 11:59 pm
First copy the file "gradefile.txt" which is available in our class folder (full path: P:\\Class\\Math\\Aydin\\118\\FilesForLabs) into your own folder. DO NOT modify this file! (even after copying it into your folder)
Then write a program which does the following
1. Open gradefile.txt (from your own folder) and copy its content EXACTLY to another file in your folder. Call this output file gradeout.txt. Make sure it is an exact copy (including spacing).(Hint: use the member functions get and eof ). Close the file gradeout.txt after this operation.
2. As you see, this file contains a number of test scores. You will read the data from the gradefile.txt again. This time use another ifstream object to read the file a second time. Read every score as an integer (as opposed to regarding them as characters) and store in an integer array or vector. (You may assume that there are at most 100 scores). Find the number of scores in this file, maximum score, minimum score and average score. Now, open the file gradeout.txt, this time with the option to append. Output all of these values BOTH to the screen and to the file gradeout.txt. The average must be a double and should put exactly 2 places after the decimal point. (So you need to do necessary formatting). APPEND these data to the file gradeout.txt.
For part 1. using the member function get to read would be more convenient. For part 2, the extractor operator >> may be more useful. (See the relevant examples discussed in class).
3. Also output all the scores in descending order, and the median score both to the screen and to the file gradeout.txt
As usual, you will be graded on the following criteria: fulfillment of all requirements in problem statements, correct output, good user interface, good coding style and formatting. 100 points.