I posted last night on this program but am now running into a different problem, even though i think it is the same issue
here is the code
Code:
/*
Jessie Brown
cop2334
*/
#include "Student.h"
//Prototypes -- function declarations.
//-----------------------------------
void Menu_Selection();
void enter_students (int,int& total);
int main()
{
Menu_Selection();
// the following lines keep the console open
cout << "\nPress <ENTER> to continue.\n";
fflush(stdin);
cin.get();
return 0;
}
/*------------------------------------------------------------------------------
This section of code is the initial screen after employee signs in
to system. From here said employee can choose what she must
do with each customer being assisted.
------------------------------------------------------------------------------*/
void Menu_Selection()
{
Student student[STUDENT_LIMIT];
int total=0, examnumber=0;
int exam[EXAM_LIMIT];
int studentID;
int option;
do
{
cout << endl
<< "1. Add a new student to roster. \n \n"
<< "2. Enter exam score for all students. \n \n"
<< "3. Display student exam averages. \n \n"
<< "4. Display course information for all students. \n \n"
<< "5. Exit program: \n \n";
cin >> option;
cout << endl;
switch (option)
{
case 1:
enter_students (STUDENT_LIMIT,total);
cout << endl;
break;
case 2:
cout << "works 2";
cout << endl;
break;
case 3:
cout << "works 3";
cout << endl;
break;
case 4:
/*------------------------------------------------------------------------------
This function prints all acounts listed in the "bank array" as well as thier
corresponding balances.
----------------------------------------------*/
for( int i = 0; i < total ; i++ )
{
Student studentTemp;
cout << studentTemp.getFullName() << endl;
cout << "ID: " << studentTemp.getID() << endl;
}
break;
case 5:
cout << "End of Program.\n";
break;
default:
cout << "Not a valid option. Please choose a valid option. \n\n";
}
}while (option != 5);
}
/*------------------------------------------------------------------------------
This function allows a user to add an account with its beginning balance.
accounts are to be sorted and no to account numbers are to be the same
------------------------------------------------------------------------------*/
void enter_students (const int STUDENT_LIMIT, int& total)
{
string temp1;
string temp2;
Student studentTemp;
int tempID;
if(total >= STUDENT_LIMIT)
{
cout <<"Registration closed for this section.\n";
}
else if(total <STUDENT_LIMIT)
{
cout <<"Please enter students first name.\n";
cin >> temp1;
cout <<"Please enter students last name.\n";
cin >> temp2;
studentTemp.setName(temp1,temp2);
cout << "Enter student ID.\n";
cin >> tempID;
studentTemp.setID(tempID);
cout << studentTemp.getFullName() <<endl;
cout << "ID: " << studentTemp.getID() << endl;
total++;
}
}
it compiles with no errors,
option number one works
option number 4 prints out -1
I know it is how i am trying to use the class but just can not get it
I am not even sure that it is storing the data in a new object each time i implement number 1
any insight is helpful
thanks
jessie