So i started off on the wrong foot with this assignment, i started by using a set ammount of students, but i did it wrong cause i won't know how many students there will actually be.
the project is going to open a txt file that contains information such as:
the 3 stands for number of student, 6 for how many graded tests and 600 for over all points.
(the file will be different from what the instructor will use, and will have more or less students then example file)
my question is how do i get my program to read in the data for each student without having a set number of students. here is what i have so far and reading the file works, but this is where i am stuck at, please help..
the main goal is to read in the text file
show the student id and overall grade percentage and letter grade
example:
Student ID Percentage Grade
---------- ---------- -----
1479 89% B
i can do the display i understand that, but manipulating the data into seperate students, note: i cannot use arrays on this assignment, thats how i did it wrong the first time through.
my question is how do i get my program to read in the data for each student without having a set number of students.
Try a vector. You can use the push_back member function to add elements to it, so you don't need to know how many students you'll have.
The index number could be the student number, and each value is the score. Maybe another vector for max, too.
// Once for each student
for(int s = 0; s < numberStudent; ++s)
{
// Read in a student
int id;
int score[grade];
int percent;
// read in id here
// once for each grade
for(int g = 0; g < grade; ++g)
{
// read in each score
}
// calculate percent and grade
// then output id , percent and grade
}