Organizing student records read in from a file (name capitalization, letter grade, credit, class name etc)

I have a student file with this information:

johN SMiTh
A 3 introductory spEEch
B 5 PrecalculuS 1 and 2
A 4 United States GOVERNMENT
*
mArY AdAms
C 3 cUltUrAl AnthrOpOlOgY
B 1 eNGiNeeRiNG PHySiCS 1 LaB
F 3 Engineering physiCS 1
A 4 calculus 1
*
ROBERT wilson
*
And I'm trying to output it more organized and labeled:
Maybe something like this:

Smith, John

Course Name: Introductory Speech
Grade: A
Credit: 3
Course Name: Precalculus 1 And 2
Grade: B
Credit 5
Course Name: United States Government
Grade: A
Credit: 4
GPA: 3.583
Total Credits: 12


etc..
etc..

Wilson, Robert
No courses taken this semester.


Here is what I have so far, but for some reason my output is clumping all the information together without separating the name from the credits from the letter grade etc.

Any help is appreciated thank you!


#include <iostream>
#include <fstream>
#include <string>
#include <cctype>

using namespace std;

int main()
{

ifstream infile;
string file_name, first_name, last_name, class_name, data;
int credits;
float gpa;
char letter_grade;
float grade_num;

cout << "Please enter your file name" << endl;
getline(cin, file_name);

infile.open(file_name.c_str());

while (infile){


infile >> first_name >> last_name >> letter_grade >> credits >> class_name;
cout << first_name << endl;

}
return 0;
}
Last edited on
Can you post the text document info here? Im stuck on my hw so il try yours to see if i can help ha
Last edited on
Topic archived. No new replies allowed.