I am trying to use functions in the following program. The program is supposed to use a vector of structures to store a students first name, last name, and grades. Also, to get a average for each student and a class average. I do not think I am calling the function with the right parameters, but I am completely stuck. Any help would be greatly appreciated.
#include <iostream>
#include <string>
#include <vector>
#include <conio.h>
#include <algorithm>
using namespace std;
struct Student{
string fName;
string lName;
vector<double>exams;
};
void display_Student(const Student& student);
double studentAverage(const Student& , double average);
int main(){
int count;
double average;
const int NUM_EXAMS = 5;
double examScore;
int numStudents = 0;
vector<Student> students;
cout << "Number of students: " << endl;
cin >> numStudents;
for (int i = 0; i < numStudents; i++){
Student student;
cout << "Enter the first name for student #" << i+1
<< ": " << endl;
cin >> student.fName;
cout << "the first name of the student is: " << student.fName << endl;
cout << "Enter the last name for student #" << i+1
<< ": " << endl;
cin >> student.lName;
cout << "the first name of the student is: " << student.fName << endl;
for (int j = 0; j < NUM_EXAMS ; j++ ){
cout << "Enter the exam scores student #" << i+1 << " exam #" << j + 1
<< ": " << endl;;
cout << " Exam #" << j+1 << ": ";
cin >> examScore;
student.exams.push_back(examScore);
}// end of nested for loop
students.push_back(student);
}//end of for loop
// display the student
for (int n = 0; n < students.size(); n++){
display_Student(students[n]);
}// end of the for loop
studentAverage(students, average);
_getch();
return 0;
}//end of main
double studentAverage(const Student& students, double average){
double total = 0;
for(int i = 0; i < Student.exams[i]; i++){
total += exams[i];
}// end of the for loop
average = total / 5.0;
cout << "The average for " << student.fName << "is:" << average << endl;
}// end of the double studentAverage(const Student& , double average)function
void display_Student(const Student& student){
cout << student.fName << " " << student.lName;
for (int n = 0; n < student.exams.size(); n++){
cout << " " << student.exams[n];
cout << endl;
}// end of the for loop
}// end of the void display_Student(const Student& student) function