Well, I'm mostly done with this project, it sorts a list of 25 students with their gpas and standing and such into alphabetical order, and calculates the gpa average.
I now only have to sort the freshmen, sophomores, juniors, and seniors into their own lists, alphabetize them and then calculate their gpa.
But I am having an issue getting them into their own lists.
I created a new instance of my class Students for each standing, either freshmen, junior, etc, with an array of how many there are (it's fixed).
Here is the whole of the code, I know it's messy and my coding style is crappy but eh. I marked with a comment where the program works up to, but here's a snippet of the faulty code, and the file information it reads. What the following snippet should do is get the last name, first name, and standing of the first person in the list, and put this information into a dummy instance of the class. It then should check if their standing is Freshmen, Sophomore or what have you. If it is a freshman (the first person in the list is) then it should get their final peice of information via the GPA function which also moves the virtual cursor down to the next line. It sets the information previously put into the dummy instance of the class into the correct place depending on the if statement, Freshman, or sophomore, etc.
However when I throw in some random couts to check if the data is all correct and everything...
http://i.imgur.com/CNWJtPg.png
It appears blank... I don't get it... at all...
Williams, Leonard - Freshman - 1.85 -
Smith, Shelia - Senior - 2.99 -
Anderson, Andy - Sophomore - 3.01 -
Wiser, Bud - Freshman - 4.00 -
Robertson, Jully - Junior - 2.78 -
Koran, Korn - Junior - 3.50 -
Smith, Sam - Junior - 2.14 -
Johnson, Jim - Junior - 3.05 -
Johnson, Jane - Junior - 3.75 -
Potter, Pam - Senior - 2.98 -
Brown, Bill - Sophomore - 2.55 -
Crooks, Cathy - Freshman - 1.99 -
Gregg, Howard - Senior - 2.44 -
Nicholas, Judy - Senior - 3.69 -
White, Bob - Sophomore - 1.64 -
Walsh, Fred - Junior - 4.00 -
Dennis, Susan - Senior - 2.06 -
Roberts, Rachel - Sophomore - 4.00 -
Fredericks, Mary - Freshman - 2.89 -
Holmes, Wendy - Senior - 2.56 -
Edwards, James - Sophomore - 3.00 -
Green, Barbara - Sophomore - 3.67 -
Brown, David - Freshman - 2.00 -
Williamson, Walt - Sophomore - 2.95 -
Carson, Jim - Sophomore - 2.03 -
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
else if (affirm == 'f' || affirm == 'F')
{
int NumDummy = 0;
int NumFresh = 0;
int NumSen = 0;
int NumJun = 0;
int NumSoph = 0;
ins.open(infile);
do
{
TempStu2[NumDummy].GetLastName();
TempStu2[NumDummy].GetFirstName();
TempStu2[NumDummy].GetStanding();
if (TempStu2[NumDummy].Standing == "Freshman")
{
Freshmen[NumFresh].GetGPA();
Freshmen[NumFresh].StudentLastName = TempStu2[NumDummy].StudentLastName;
Freshmen[NumFresh].StudentFirstName = TempStu2[NumDummy].StudentFirstName;
Freshmen[NumFresh].Standing = TempStu2[NumDummy].Standing;
NumFresh = NumFresh + 1;
}
else if (TempStu2[NumDummy].Standing == "Sophomore")
{
Sophomores[NumSoph].StudentLastName = TempStu2[NumDummy].StudentLastName;
Sophomores[NumSoph].StudentFirstName = TempStu2[NumDummy].StudentFirstName;
Sophomores[NumSoph].Standing = TempStu2[NumDummy].Standing;
Sophomores[NumSoph].GetGPA();
NumSoph = NumSoph + 1;
}
else if (TempStu2[NumDummy].Standing == "Junior")
{
Juniors[NumJun].StudentLastName = TempStu2[NumDummy].StudentLastName;
Juniors[NumJun].StudentFirstName = TempStu2[NumDummy].StudentFirstName;
Juniors[NumJun].Standing = TempStu2[NumDummy].Standing;
Juniors[NumJun].GetGPA();
NumJun = NumJun + 1;
}
else if (TempStu2[NumDummy].Standing == "Senior")
{
Seniors[NumSen].StudentLastName = TempStu2[NumDummy].StudentLastName;
Seniors[NumSen].StudentFirstName = TempStu2[NumDummy].StudentFirstName;
Seniors[NumSen].Standing = TempStu2[NumDummy].Standing;
Seniors[NumSen].GetGPA();
NumSen = NumSen + 1;
}
} while (!ins.eof());
ins.close();
|