I need to figure out what is wrong with this. I need the average of
the scores to be calculated in the AverageGrade function, but I am
having problems. Can someone help me?
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
class Person
{
protected:
char m_FirstName[30];
char m_LastName[30];
public:
void SetFirstName(char []);
char * GetFirstName(void);
void SetLastName(char []);
char * GetLastName(void);
};
class Student : public Person
{
protected:
char m_NID[30];
float m_Grade;
public:
void SetNID(char []);
char * GetNID(void);
void SetGrade(float);
float GetGrade(void);
};
float AverageGrade(Student [], int);
//int MaximumGradeStudent(Student [], int);
void main()
{
Student *studentInfo;
char studentFName, studentLName, studentNID;
float studentGrade;
int i,n;
cout << "Enter the number of students: ";
cin >> n;
studentInfo = new Student[n];
for (i = 0;i < n; i++)
{
cout << "\nStudent #" << i+1 << endl;
cout << "Enter the student's first name: ";
cin >> studentFName;
cout << "Enter the student's last name: ";
cin >> studentLName;
cout << "Enter the student's NID: ";
cin >> studentNID;
cout << "Enter the student's grade: ";
cin >> studentGrade;
studentInfo[i].SetFirstName(&studentFName);
studentInfo[i].SetLastName(&studentLName);
studentInfo[i].SetNID(&studentNID);
studentInfo[i].SetGrade(studentGrade);
}
}
float AverageGrade(Student studentGrade, int average)
{
int i;
float n;
float AveSco = 0.0;
bool validString = true;
for(i=0;i<n;i++)
{
AveSco = AveSco + n;
};
AveSco = AveSco / n;
cout << "The average student grade is: " << AveSco << endl;
return AverageGrade;
};