Code:
#include <iostream>
#include <vector>
using namespace std;
class GradeBook {
public:
double getGrades()
{
double total=0.0;
int amount;
cout<<"Enter the amount of grades you need to enter"<<endl;
cin>>amount;
cout<< "Enter the students Grades: "<<endl;
for (int i =0; i < amount; ++i) {
vector<int> grades(amount);
cin>>grades[i];
total += grades[i];
}
averageGrades(total, amount);
return total;
}
double averageGrades(double total , int num)
{
double average = 0.0;
average = total / num;
return average;
}
void letterGrade()
{
double grade=0.0;
int number=0;
cout<<averageGrades(grade, number)<<endl; // test to see if values are being passed
}
private:
};
int main(int argc, const char * argv[])
{
GradeBook GradeTracker;
GradeTracker.getGrades();
GradeTracker.letterGrade(); // this is returning "nan"
return 0;
}
I changed it up a little. I am just testing at this point to see is my values are being passed correctly and they are not. What am I doing wrong?