Hi all,
I need to create a for loop for five students using my class. In that for loop, I need to have another loop that asks for the grade for each of the three grades and then call the examScore function in the Student class. How can I do this using what I already have in my main function?
first you need an array of objects of Student class, then an array of exam grades something like this :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Student stud [ 5 ];
double exam [ 3 ];
// I need to create a for loop for five students using my class :
for ( int i = 0; i < 5; ++i ) {
stud [ i ].someFunction ();
// In that for loop, I need to have another loop that
// asks for the grade for each of the three grades
for ( int j = 0; j < 3; ++j ) {
// Prompt
cin >> exam [ j ];
stud [ i ].someFunction ( exam [ j ] );
}
// compute
}