LAB 9: FILE I/O

Due: 9:30 am, Tuesday 10/29

For this lab, first copy the file "gradefile.cpp" which is available in our class folder (full path: P:\\class\\math\\aydin\\Math118\\gradefile.cpp) 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.cpp (from your own folder) and copy its content EXACTLY to another file in your folder. Call this output file gradeout.cpp. Make sure it is an exact copy (including spacing). (Hint: use the member functions get and eof )

2. As you see, this file contains a number of test scores. Read every score and store in an integer array. (Assume that there are at most 100 scores). Find the number of scores in this file, maximum score, minimum score and average score. Output all of these values BOTH to the screen and to the file gradeout.cpp. 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.cpp.

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 last paragraph on page 275 of the textbook).


3. Also output all the scores in descending order, and the median score both to the screen and to the file gradeout.cpp