Reference no: EM132164312
Using C++
On my computer, I've got two grade files. One contains the grades from the first mid-term (mt1.txt), and the other contains the grades from the second mid-term (mt2.txt). Each file has exactly the same format: a lot of lines each containing the name of the student (they are all quite famous, so they all have just one single short name) followed by four integer grades. Plus, the lines are all in alphabetical order. Here is a very small example of the two files (the real ones are quite long):
mt1.txt:
Bambi 25 13 30 0
Cher 11 21 17 1
Frank 31 25 26 1
Madonna 3 7 0 1
Zelda 19 28 25 1
mt2.txt:
Bambi 31 27 17 0
Cher 26 19 21 1
Frank 33 20 24 1
Madonna 0 5 0 0
Zelda 33 29 33 1
As you can see, the two files have grades for the same students in the same order. A. Write a program that would read two files just like these (but longer) and combine them into a single file containing one line for each student, in the same order, with that one line now containing all eight of the student's grades. For the example above, the new file would be:
allmt.txt:
Bambi 25 13 30 0 31 27 17 0
Cher 11 21 17 1 26 19 21 1
Frank 31 25 26 1 33 20 24 1
Madonna 3 7 0 1 0 5 0 0
Zelda 19 28 25 1 33 29 33 1
Write very clearly and leave yourself a lot of space, because for part B, you will be modifying this program. Try to make it a whole program, with the correct C++ #includes, not library.h.
Although this is not a major requirement. Most of the points are for part A. B. Sometimes students are frightened by the first mid-term and drop the class. This means that the second file might have some people missing from it. The files could be something like this:
mt1.txt:
Bambi 25 13 30 0
Cher 11 21 17 1
Frank 31 25 26 1
Madonna 3 7 0 1
Zelda 19 28 25 1
mt2.txt:
Bambi 31 27 17 0
Frank 33 20 24 1
Zelda 33 29 33 1
But at least the two files will still be in alphabetical order. Show the modifications to your program that would be required to handle dropped students properly. When a student does not appear in the second file, the new file should still show their grades from the first mid-term. So for the new example, the output would be:
allmt.txt:
Bambi 25 13 30 0 31 27 17 0
Cher 11 21 17 1
Frank 31 25 26 1 33 20 24 1
Madonna 3 7 0 1
Zelda 19 28 25 1 33 29 33 1