I am lost again, I know that there is a way to use push_back to add to the vector, but I am at a loss for how I can actually get it to work. What I am trying to do is add 5 students to a vector (Egrades), and with each student gather 3 separate exam scores and attach them to that students name so that I can compute the averages later.
In my code below, I took out the lines in the cases, and only put student 1 to cut down length.
Where am I going wrong? Did I forget to put something in?
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
int main(void)
{
// Delcarations
int score1;
int score2;
int score3;
int scores[5];
vector <int> Egrades;
string student1;
string student2;
string student3;
string student4;
string student5;
// array with menu options
string menu[15];
menu[0] = " **************";
menu[1] = " *** MAIN MENU ***";
menu[2] = " **************";
menu[3] = " Please Choose From The Following Options:";
menu[6] = " 1. Add Student:";
menu[8] = " 2. Compute Student Test Score Average:";
menu[10] = " 3. Search A Student Average Test Score:";
menu[12] = " 4. Compute The Average Of The Average Exams:";
menu[14] = " 5. Exit";
char selection;
cout << "\t\t\t Enter Your Selection: ", cin >> selection, cout << endl;
switch (selection)
{
case '1':
system("CLS");
do
{
{
cout << "Student Information Section:\n\n";
// Student 1 Info
cout << "Enter Student 1 Name:\n";
cin >> student1; cout << endl;
cout << "Enter Exam 1 Score: ";
cin >> score1; cout << endl;
cout << "Enter Exam 2 Score: ";
cin >> score2; cout << endl;
cout << "Enter Exam 3 Score: ";
cin >> score3; cout << "\n" << endl;
}
system("pause");
return main();
}
while (cin >> score1, score2, score3);
break;
case '2':
break;
case '3':
break;
case '4':
break;
case '5':
exit(-1);
break;
default: cout << "\n Invalid selection\n\n";
}
return 0;
}