// Example file for 375
//
// Description: A program to compute a weighted average. This will be the example
// file we use to introduce various concepts. Here arrays are introduced.
// Date: Jan 8  2015
// Author Deborah R. Fowler
// Note that your comments should be defined by your algorithm
// In class we will step thru arrays, vectors and finally using a student class using OOP
// We will discuss in class the design choices for various solutions.
//

#include <iostream>
using namespace std;
int const MAX_ARRAYSIZE = 100;

int main()
{
	float grades[MAX_ARRAYSIZE];
	float weight[MAX_ARRAYSIZE];
	
	// Read in the number of grades
	int numberOfGrades;
	cout << "Enter number of grades\n";
	cin >> numberOfGrades;
	
	// Read in the weighting for each exercise
	for (int i = 0; i < numberOfGrades; ++i)
	{
		cout << "Enter weighting(in percent)for Exercise " << i+1 << "\n";
		cin >> weight[i];
		// Since the user is entering weight by percent, convert it to decimal
		weight[i] /= 100;
	}
	// This would be a good place to error check to ensure the user has entered 
	// weights that total to 100 and require them to re-enter them - we will do 
	// this as an in-class exercise
	
	// Read in the grades and process them
	// Eventually will be made into repeated set of code 
	// (loop, then a function call in a loop) to process many students
	//
	// Make sure you initalize your sum to zero
	float weightedAverage = 0;
	for (int i = 0; i < numberOfGrades; ++i)
	{
		cout << "Enter grade for Exercise " << i + 1 << "\n";
		cin >> grades[i];
		weightedAverage += weight[i] * grades[i];
	}
	
	// Print the result
	cout << "Hello, your weightAverage is " << weightedAverage << "\n";
	
	return 0;
}