//Andrew Alspaugh                   CS1A            Chapter 7. P. 444. #2
 
////////////////////////////////////////////////////////////////////////////////
//Process Rainfall Values
 
//This program displays the annual rainfall, average monthly rainfall, the month
//the most rainfall, and the month with the least rainfall.
//____________________________________________________________________________
//INPUTS
 
//  SIZE       // array declerator
//  MONTH      // array which holds values of rainfall per month
//OUTPUTS
 
// RainAnnual  // Rainfall Per YEar
// AverageRain // Average Rainfall Per Month
 
// highest     // highest amount of rainfall
// highMonth   // Month with the Most Rainfall
 
// lowest      // lowest amount of rainfall
// lowMonth    // Month with Least Rainfall
///////////////////////////////////////////////////////////////////////////////
 
#include <iostream>
using namespace std;
 
int main() 
{
//DATA DICTIONARY/////////////////////////////////////////////////////////////
 
//INPUTS//
    const int SIZE = 12;
    double MONTH[SIZE];
 
//OUTPUTS//    
    double RainAnnual = 0;
    double AverageRain = 0;
 
    double highest;
    int highMonth;
 
    double lowest;
    int lowMonth;
 
//INPUT////////////////////////////////////////////////////////////////////////
 
    for (int count = 0; count < SIZE; count++)      //input rainfall per month
    {
    	cout << "Enter Rainfall Amount for Month " << (count + 1) << " : " ; 
    	cin >> MONTH[count];
 
    	while (MONTH[count] < 0)     // Validate Inputs
    	{
    		cout << "INVALID: INPUT CANNOT BE NEGATIVE" << endl;
    		cin >> MONTH[count];
    	}
    	cout << MONTH[count] << endl;
 
    	RainAnnual += MONTH[count];      //ACCUMULATOR FOR ANNUAL RAINFALL
    }
 
//PROCESS//////////////////////////////////////////////////////////////////////
 
    //AVERAGE MONTHLY RAINFALL
    AverageRain = RainAnnual/(SIZE);
 
    //MONTH WITH MOST RAIN
    highest = MONTH[0];
    for (int i = 1; i < SIZE; i++)
    {
    	if (MONTH[i] > highest)
    	{
    	highest = MONTH[i];
    	highMonth = i;
    	}
    }
 
    //MONTH WITH LOWEST RAIN
    lowest = MONTH[0];
    for (int i = 1; MONTH[i] > lowest; i++)
    {
    	if (MONTH[i] > lowest)
    	{
    	lowest = MONTH[i];
    	lowMonth = i;
    	}
    }
 
//OUTPUT///////////////////////////////////////////////////////////////////////
    cout << endl;
 
    cout << "Annual Rainfall This Year Was: " << RainAnnual << endl;
 
    cout << "Average Rainfall Per Month Was: " << AverageRain << endl;
 
    cout << "Month With Most Rain Was: Month " << highMonth << endl;
 
    cout << "Month With Least Rain Was: Month " << lowMonth << endl;
 
 
	return 0;
}