Calculating GPA with input file

Text File
4
Mickey 3 A 2 B 3 A 4
Donald 5 C 2 B 3 C 3 D 1 A 3
Pluto 4 B 4 A 3 C 3 B 4
Goofy 3 D 4 C 3 F 3

Output file
NAME TOTAL HOURS GPA
Mickey 9 3.667
Donald 12 2.667
Pluto 14 3.000
Goofy 10 1.000

I need help setting up how to get the input file to look like the output file on the terminal


closed account (zb0S216C)
OK. Here's my immediate thoughts: Each line represents a student. A student can be represented as a single structure. Each field on a single line is a separate data member within the structure.

By looking at the file, I've seen the number 4, which appears before the student entries. I'm assuming that's the student entry count. If that's the case, extract the number and then dynamically create an array of 4 students. After that, iterate through the array. With each cycle, extract all fields on a single line.

When all extractions are complete, iterate through the array again (or fuse the two loop together) and print the students information to the console with std::cout. When all is gravy, delete the array before exiting the program.

Wazzak
Last edited on
I have no idea how to set it up i've tired many times and it has failed
closed account (zb0S216C)
If possible, post your failed code and we'll go from there. A flow diagram always helps.

Wazzak
The thing is i don't know how to start this thing i know how to have it read in from a text file but then i don't know how to set it up. How do i set up the code to read theres going to be 4 students and then to categorize each student with the number of courses they took. i know how to calculate the gap i just don't know what code to use to bring the info in a certain order and to repeat itself for every student even if its 4 students or 400
Topic archived. No new replies allowed.