read a file containing a list of students' names followed by their test scores. Define a structure to store name and score. Instead of just a vector of scores, you will now need a vector of structures. Each element in the vector will have the student's name and the average of his or her score. Your program needs to be able to sort the vector by both name and score, so you need to implement two different compare functions to pass to sort:
Display the scores sorted by name and score, the class average and median. No matter how the data is sorted, you should print both name and score. For example, students sorted by name:
Ana 73
Daniel 66
Problem:
I've created the compareByName and compareByScore, but my compiler says that
my compaireByScore sort has "invalid arguments." Am I missing something or
did I do something completely wrong.
This function reads through the text file and calculates the class
average
*******************************************************************/
double classAverage(vector<double> numbers)
{
double averages;
int total = 1;
int g = 0;
int size = 110;
int start = 0;
Student student;
while (start < 110)
{
for(int i = g; i < size; i++)
{
student.name = g;
for (int j = 1; j < size; j++){
total += numbers[i];
}
}
averages = total / 10;
start = size;
size += 10;
g += 10;
total = 0;
}
return (averages/10);
}