Hello, I am nearly finished with this assignment, except, for the part where I need to get the letter grade. I have an array that stores each of the scores for each student but I am unsure on how to go about finding the letter grade equivalent of each averaged grade for each student. Here is the code I have so far. It is working great, but I am unsure on how to implement a way of finding the letter for each score.
# include <iostream>
# include <string>
usingnamespace std;
int sum(int score[]) //Adds together the three scores for each student.
{
int sum = 0;
for (int i = 0; i < 3; i++)
{
sum += score[i];
}
return (sum / 3);
}
int main()
{
int studentNum = 0;
int studentScores = 0; // The score for each student before it is averaged
int numScores = 3; //The amount of scores to average together for each student.
cout << "How many students do you need to record information for?" << endl;
cin >> studentNum;
//---------------------------------------------------------------------------- Arrays
string studentName[studentNum]; //Array that holds each of the students names.
int studentId[studentNum]; //Array that holds each of the students id numbers.
int studentScore[studentNum][numScores]; //Array that holds each of the students three scores.
//----------------------------------------------------------------------------End of Arrays
cout << "Enter the name for each student below. " << endl; //Gets the name of each of the students.
for (int i = 0; i<studentNum; i++)
{
cout << "Enter the name of the student " << i + 1 << ". -> ";
cin >> studentName[i];
}
for (int i = 0; i < studentNum; i++) //Gets the id number for each of the students.
{
cout << "Enter the student id for " << studentName[i] << endl;
cin >> studentId[i];
}
cout << "Please enter the three scores for each of the students." << endl; //Gets the 3 test scores for each of the students.
for (int i = 0; i < studentNum; i++)
{
for (int j = 0; j < 3; j++)
{
cout << studentName[i] << ": ";
cin >> studentScore[i][j];
}
}
for (int i = 0; i<studentNum; i++) //Displays the name and id number of each student.
{
cout << "Student Name: " << studentName[i] << endl << "ID: " << studentId[i] << endl << "Students Scores: " << sum(studentScore[i]) << endl;
}
}
Thanks for any help or advice you can give.
-Torm04