// Yousef Rabah         
#include "CS35lib.h"

double give_back(double score[])
{  
   double highest_sco = 0;
   int sum = 0, counter;
   for (counter=0; counter <= 4; counter++)
   {
      
      if ( score[counter] > highest_sco)
      {
      	highest_sco = score[counter];
      }
      
   }
   return highest_sco;
 }


int main ()
{
   int counter, i, number;
   double score[5], highest_sco, sum, average, high;
   char Y_or_N;
   
   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: \n\n";
   highest_sco = 0;
   sum = 0;
   for (counter=0; counter <= 4; counter++)
   {
      cout<<"Quiz "<<counter+1<<": ";
      cout<<score[counter];
      high = give_back(score);
      
      sum = sum + score[counter];
      average = sum / 5;
      cout<<"\n";
   }
   cout<<"Do you want to correct any of these? ";
   cin>>Y_or_N;
   if ((Y_or_N == 'Y') || (Y_or_N == 'y')) 
   {
      cout<<"Which quiz number? ";
      cin>>number;
      cout<<"That score is presently "<<score[number-1]<<".";
      cout<<"  What should it be? ";
      cin>>score[number-1];
      cout<<endl<<endl;
      highest_sco = 0;
      sum = 0;
   	for (counter=0; counter <= 4; counter++)
      {
            cout<<"Quiz "<<counter+1<<": ";
            cout<<score[counter];
            
          high = give_back(score);
            sum = sum + score[counter];
            
            average = sum / 5; 
            cout<<"\n";
      }
    } 
   
    cout<<"\n\n";
    cout<<"Your highest score is "<< high<<". \n";
    cout<<"Your average is "<<average;
    cout<<endl;
   
   
   
   
   
   return 0;
   
}
   
