Within my program i am supposed to assign one array (student_name) with grades by using a parallel array (grades). i'm not sure how to assign the student_name array with the grades by using a parallel array. in my program i have found out the average of each student so i know their scores and what their grades should be, but i'm not sure how to go about it using the parallel array. i've already made the parallel array and it's ready to be used. here's a sample of my code of how i think it's supposed to look
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
|
for (a = 0; a < 10; a++)
{
cout << left << setw(14) << student_name[a] << ": ";
for (b = 0; b < 5; b++)
{
average += student_score[a][b];
}
average = average / 5;
if (average <= 100 && average >= 90)
{
//student_name[a] receives A
}
else if (average < 90 && average >=80)
{
//student_name[a] receives B
}
else if (average < 80 && average >=70)
{
//student_name[a] receieves C
}
else if (average < 70 && average >= 60)
{
//student_name[a] receieves D
}
else if (average <= 50 )
{
//student_name[a] receives F
}
average = 0;
}
|
at the end i assign average to 0 because the program would continue to add on number to the average. i would prefer to keep that there, it helps me and it works like that. but if there's a more cleaner way or more efficient way than assigning average to 0 at the end please give me your input. if it helps i'll also post the txt file.
Mary Peterson, 95, 93, 77, 94, 77,
Jake Andersen, 90, 90, 95, 93, 49,
Susan Cooper, 79, 94, 44, 90, 73,
Mike Smith, 95, 93, 30, 79, 97,
Jim Blair, 53, 45, 97, 39, 59,
Clark Lee, 70, 95, 45, 39, 77,
Kennedy Davis, 77, 34, 55, 74, 93,
Kim Bronson, 93, 94, 99, 77, 97,
Sunny Hill, 79, 95, 59, 93, 95,
Sam Benson, 95, 75, 49, 75, 73,