The following program accepts five student names and 4 test scores for each. Then calculates and displays the average and letter grade for each students. Well, that is what it is supposed to do. Judging by the long list of errors I get, it looks like none of my arguments are being successfully passed. Any help would be greatly appreciated!
#include <iostream>
#include <iomanip>
using namespace std;
char getStuNames(char*[21], int);
double getStuGrades(char*[21], double**, int, int);
void displayGrade(char*[21], double**, int, int);
int main() {
const int stu = 5;
const int num = 4;
char stuNames[stu][21];
double stuGrades[stu][num];
getStuNames(stuNames, stu);
getStuGrades(stuNames, stuGrades, stu, num);
displayGrade(stuNames, stuGrades, stu, num);
cout << "\n\n\n\n";
return 0;
}
/**************************************************/
char getStuNames(char*[21] stuNames, int stu) {
for (int i = 0; i <= stu; i++) {
cout << "\n\n\t\tGrade Book"
<< "\n\t\t_____________________________________________"
<< "\n\n\t\tEnter name of student " << ( i + 1 ) << ": ";
cin.get(stuNames[i][21]);
cin.ignore();
}
return stuNames[stu][21];
}
/**************************************************/
double getStuGrades(char*[21] stuNames, double** stuGrades, int stu, int num) {
for (int i = 0; i < stu; i++) {
cout << "\n\n\t\tGrade Book"
<< "\n\t\t_____________________________________________"
<< "\n\n\t\tGrades for student: " << setw(25) << stuNames[i][21] << " ";
for (int j = 0; j < num; j++) {
do {
cout << "\n\n\t\tEnter score " << ( j + 1 ) << ": ";
cin >> stuGrades[j];
}while (stuGrades[j] < 0 || stuGrades[j] > 100);
}
}
return stuGrades[stu][num];
}
/**************************************************/
double getAvg(double stuGrades**, int i, int num) {
// Calculate Total For Each Student
double total = 0;
for (int j = 0; j < num; j++) total += stuGrade[i][j];
// Calculate Average
double average = (total / num);
return average;
}
/**************************************************/
char getLet(double average) {
// Determine Letter Grade
char letter;
if (average > 89) letter = 'A';
else if (average > 79) letter = 'B';
else if (average > 69) letter= 'C';
else if (average > 59) letter = 'D';
else letter = 'F';
return letter;
}
/**************************************************/
void displayGrade(char*[21] stuNames, double** stuGrade, int stu, int num) {
int i;
cout << "\n\n\t\tGrade Book"
<< "\n\t\t_____________________________________________"
<< "\n\n\t\tStudent Average(%) Letter Grade";
cout << setprecision(1) << showpoint << fixed;
for (i = 0; i < stu; i++) {
double average = getAvg(stuGrade, i, num);
char letter = getLet(average);
cout << "\n\t\t"
<< setw(21) << stuNames[i][21]
<< setw(5) << average
<< setw(14) << letter;
}
}