//Section11_Group5
//MUHAMMAD AMIRUL BIN ISMAIL
// HOW KAH HUI
/*This program is to calculate average of rain fall every year that entered by User
and total rainfall in inches*/
#include <iostream>
#include <iomanip>//this for setprecision
using namespace std;

int main()
{
	int years;
	const int months = 12;
	float rainfall;
	float totalRainfall=0;
	float average;
	
	cout << "Please enter number of years" << endl;// ask the user to enter the number of year
	cin >> years;
	
	while (years < 1)
	{
		cout << "Number of years must be at least 1." << endl;//The user must enter the positive number of year
		cout << "Please enter number of years" << endl;
		cin >> years;
	}
	
	for ( int i = 1; i <= years; i++)//this loop is for year
	{
		for( int numMonth =1; numMonth <= months; numMonth++)//this loop is for month
		{
			cout << "Please enter the rainfall for " << numMonth << " months: ";
			cin >> rainfall;
			totalRainfall += rainfall;
			while (rainfall < 0)
			{
				cout << "The rainfall cannot be negative number. Please re-enter: ";
				cin >> rainfall;
			}
		}
	}
	

	 cout << "The number of months: " << years*months << endl;
	 
	 cout << "The total inches of rainfall is " << totalRainfall << " inches." << endl;
	 
	 average = totalRainfall / (years*months);
	 cout << setprecision(4) << fixed << showpoint;//to show 4 decimal point
	 cout << "The average rainfall per month for the entire period is " << average << endl;

return 0;
}

