I am trying to display the sNames vector. I am not sure if I am storing the information correctly. Any help would be greatly appreciated. Also I am trying to get an average for each students exam grades and a class average, and I am not sure how to go about this.
#include <iostream>
#include <string>
#include <vector>
#include <conio.h>
#include <algorithm>
using namespace std;
struct Student{
string fName;
string lName;
vector<double>exams;
};
int main(){
int count;
const int NUM_EXAMS = 5;
Student tempFName, tempLName;
double tempExam;
int numStudents = 0;
vector<Student> sNames;
vector<Student>::iterator iter;
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;
sNames.push_back(student);
cout << "the first name of the student is: " << student.fName << endl;
cout << "Enter the last name for student #" << i+1
<< ": " << endl;
cin >> student.lName;
sNames.push_back(student);
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;;
cin >> tempExam;
student.exams.push_back(tempExam);
sNames.push_back(student);
}// end of nested for loop
//cout << sNames.student.fName << student.lName << endl;
}//end of for loop
//display the vector
for (count = 0; count < sNames.size(); count++){
cout << sNames[count] << " ";
cout << endl;
}// end of for loop
for (int i = 0; i < sNames.size(); i++){
cout << sNames.size() << " " ;
cout << endl;
}// end of the for loop
_getch();
return 0;
}//end of main