I need to write a program using arrays and strings.Here is the question.
A class of students takes a 20 question multiple-choice exam;each question has 5 choices(a,b,c,d,e)only one of them are correct.In "tests.dat"Each record of which consists of a student id, followed by a blank, followed by students 20 responses. In "answers.dat" which consists of a single record, namely the correct answers to the exam.Then It needs to produce a grade summary report like this.If the answer is correct it should put a "*" by the correct answer
student-id number correct
1231231212312 12
1233424325435 25
.... ...
question A B C D E
1 5 1 13* 3 1
2 4 7* 5 12 7
.
.
...
Is "answers.dat" supposed to contain many lines of text? I ask because you have two variables, answers_buf and correct_keys that you read from a file, then write to the variables in a loop until the end of the file, but all this is going to give you is the very last line (you write over it with each iteration of the loop.
Bookmarks