#include "CS35lib.h"

double high_score(double score[])
{  
   double highest = 0;
   int  counter;
   for (counter=0; counter <= 4; counter++)
   {
      
      if ( score[counter] > highest)
      {
      	highest= score[counter];
      }
      
   }
   return highest;
 }

double lowest_score (double score[])
{
	double lowest=10;
	int counter;
	for (counter=0; counter<=4; counter++)
	{
		if (score[counter]< lowest)
		{
			lowest=score[counter];
		}
	}
	return lowest;
}			
	
int main ()
{
   int counter, whichone;
   double score[5], highest, sum, average, high, lowest, low;
   char answer;
   
   cout<<"You had 5 quizzes this semester. Enter your scores: \n";
   for (counter=0; counter <= 4; counter++)
   {
      cout<<"Quiz "<<counter+1<<":";
      cin>>score[counter];
   }
   cout<<endl<<endl;
   cout<<"Here are your scores: "<<endl;
   highest = 0;
   sum = 0;
   for (counter=0; counter <= 4; counter++)
   {
      cout<<"Quiz "<<counter+1<<": ";
      cout<<score[counter];
      high =  high_score(score);
      low = lowest_score(score);
      sum = sum + score[counter];
      cout<<"\n";
   }
   sum = sum + score[counter]-low;
      average = sum / 4;
   cout<<"Do you want to correct any of these? please enter Y or N, if you enter";
   cout<<"anything else, the computer will consider the answer to be no. ";
   cin>>answer;
   
   if ((answer == 'Y') || (answer == 'y')) 
   {
      cout<<"Which quiz number? ";
      cin>>whichone;
      cout<<"That score is presently "<<score[whichone-1]<<".";
      cout<<"  What should it be? ";
      cin>>score[whichone-1];
      cout<<endl<<endl;
      highest = 0;
      sum = 0;
   	for (counter=0; counter <= 4; counter++)
      {
            cout<<"Quiz "<<counter+1<<": ";
            cout<<score[counter];
            
          high =  high_score(score);
          low = lowest_score(score);
        
          sum = sum + score[counter];
          
          
            cout<<"\n";
      }
      sum= sum - low;
    average = sum / 4;
    } 
    
    cout<<endl;
    cout<<"lowest is "<<low<<endl;
    cout<<"sum "<<sum<<endl;
    cout<<"Your highest score is "<< high<<"."<<endl;
    cout<<"Your average  excluding the lowest score is "<<average;
    cout<<endl;
   
   
   
   
   
   return 0;
   
}
   
