/* ++[  Machine Problem 4  ]+++++++++++++++++++++++++++++++++++++
   +                                                            +
   + Zaczek, Mariusz                                            +
   + CS 223 - Monday 11:00am - 1:00 pm                          +
   + 4/1/98                                                     +
   +                                                            +
   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */

#include <iostream.h>
#include <stdlib.h>
#include "Student.h"

int main()
{
  /* Declare variables and lists */
  int id, level;
  double score1, score2, score3;
  List Regular,Proficiency;
  RegularStudent *regStudent = NULL;
  ProficiencyStudent *profStudent = NULL;
 
  /* Test if id has been entered */
  while ( cin >> id )
  {
    /* Read in level: 1 = Proficiency , 0 = Regular */
    cin >> level;
    
    /* If Proficiency Student then calculcate score and insert 
	into linked list "Proficiency" */
    if ( level == 1 )
    {
      /* Read in 2 scores */
      cin >> score1 >> score2;

      /* Test if scores entered are between 0 and 100 and if not
         then display error message */
      if ((score1 > 100) || (score2 > 100) || 
          (score1 < 0) || (score2 < 0))
        cout << "Please enter scores between 0 and 100" << endl;

      /* Compute score and send student to linked list */
      profStudent = new ProficiencyStudent();
      profStudent->computeFinalScore(id,score1,score2);
      Proficiency.InsertStudent(profStudent);
    }
    /* If Regular Student then calculcate score and insert   
        into linked list "Regular" */
    else if ( level == 0 )
    {
      /* Read in 3 scores */
      cin >> score1 >> score2 >> score3;

      /* Test if scores entered are between 0 and 100 and if not
         then display error message */
      if ((score1 > 100) || (score2 > 100) || (score3 > 100) ||
          (score1 < 0) || (score2 < 0) || (score3 < 0))
        cout << "Please enter scores between 0 and 100" << endl;
      
      /* Compute score and send student to linked list */
      regStudent = new RegularStudent();
      regStudent->computeFinalScore(id,score1,score2,score3);
      Regular.InsertStudent(regStudent);
    }
    /* Display error message if proficiency level is not 0 or 1 */
    else
      cout << "Invalid proficiency level: " << level
           << "\nPlease use 0 for Regular or 1 for Proficiency student" << endl;
  }

  /* Display contents of linked lists separated by a newline */
  Regular.Print();
  cout << endl;
  Proficiency.Print();

  delete regStudent;
  delete profStudent;
return 0;
}
