//This programme will calculate the rainfall over a period of years in JOHOR BAHRU 
// NAME: Fathi Mohamed Fathi Rezq Bekhit 

#include <iostream>
#include <string>
#include <iomanip>

using namespace std;


int main ()
{
const int MONTHS = 12; // Number of months per year 
string name[MONTHS]= {"January","February","March","April","May","June","July","August","September","October","November","December"}; // Name of month's 
int count= 0;
int years ; 
double rain[MONTHS];
double avg;
double year=0;

	cout << "We are going to calculate the average Rainfall over a period of years in Johor Bahru, please enter the year(s): ";
	cin >> years;

	while (years < 1) // DO NOT ACCEPT NUMBER LESS THAN 1 
	{
		cout << "Please enter the years again, can't be lower than 1! \n  " ; 
		cin >> years; 
	}
	for (int i = 1; i <= years; i++) // The outter loop will iterate once each year 
{
for(count = 0; count < MONTHS; count++) // The inner loop will iterate 12 times once each month 
{
cout <<"\n How many inches of rain does "<< name[count]; 
cout<< " have? "; 
cin >> rain[count];

}
for(int count=0; count<MONTHS; count++) 
year += rain[count]; // Calculation for the total rainfall for the year 

avg = year / MONTHS; // Calculation for the average rainfall per month 

for( int count = 0; count < MONTHS; count++) 
{
cout << "\n " << name[count];
cout<< " has: " << rain[count]  << "  inches of rainfall. " ;

}

cout << endl;
cout << setprecision(2) << fixed;

cout <<"Total Rainfall for the year is " <<year << " inches" << endl;

cout <<"The average rainfall per month is " << avg << " inches"<< endl;


return 0;
}
