/***********************************************************************
* Program:
*    Assignment 31, Array Design
*    Sister Unsicker, CS124
* Author:
*    Lanie Molinar
* Summary: 
*    This program gets 10 grades from the user, averages them, and displays the
*    result.
*
*    Estimated:  2.0 hrs   
*    Actual:     1.5 hrs
*      I had some difficulty getting the style checker to not complain about 
*      my NUMGRADES constant. First, it didn't like the _ when I tried to 
*      name it NUM_GRADES, and when I tried using NUM-GRADES, it complained 
*      about there not being white space between operators. It finally stopped 
*      complaining when I used NUMGRADES.
************************************************************************/

#include <iostream>
using namespace std;

#define NUMGRADES 10

/***********************************************************************
* The function getGrades gets 10 grades from the user, passing them to main().
***********************************************************************/
void getGrades(int grades[], int num)
{
   for (int i = 0; i < num; i++)
   {
      cout << "Grade " << i + 1 << ": ";
      cin >> grades[i];
   }
}

/***********************************************************************
* The function averageGradesGrades averages the grades inputted by the user
* and returns that value to main().
***********************************************************************/
void averageGrades(int grades[], int num)
{
   int sum = 0;
   int notCompleted = 0;
   int i = 0;
   while (i < num)
   {
      if (grades[i] != -1)
      {
         sum += grades[i];
         i++;
      }
      else
         notCompleted++;
   }
   int average = sum / (num - notCompleted);
   if (notCompleted != num)
      cout << average;
   else
      cout << "---";
}

/**********************************************************************
*    The main function calls getGrades and averageGrades and displays the 
*   result returned by averageGrades.
***********************************************************************/
int main()
{
   int grades[NUMGRADES];
   getGrades(grades, NUMGRADES);
   cout << "Average Grade: " << averageGrades(grades, NUMGRADES) << "%\n";
   return 0;
}
