Reading and Writing files

I have to write a program that sorts names and grades from a file and output them to another.

For example:

Name: Peter Parker
Exam 1: 95
Exam 2: 90.625
Exam 3: 91.20

Name: Mary Smith
Exam 1: 65
Exam 2: 79.1234
Exam 3: 70.24

Becomes something like this in the output file:

Name: Parker, Peter
Average Score: 92.28
Grade: A

Name: Smith, Mary
Average Score: 71.45
Grade: C

I'm really at a lost. I know I'm supposed to read the whole file, but I'm getting really confused on how to take the name of each student separately without recording Exam 1, 2, and 3. I think if I figure that out, I'll be able to do the average score and grade on my own. So, my question is, can someone give me a nudge in the right direction?
Last edited on
you should store data line by line as you show here. then read data line by line.
you can skip no of line use skip function.
Thanks for the help, I stored the data line-by-line as you said, and I completely understood how to do the rest.
Topic archived. No new replies allowed.