0

the program should have a getData function that accepts the total rainfall for each of the 12 months from the user, and stores it in a double array. It should also have four value-returning functions that compute and return to main the totalRainfall, averageRainfall, driestMonth, and wettestMonth. The last two functions will return the number of the month with the lowest and highest rainfall amounts, not the amount of rain that fell in those months.

```
#include<iostream>
#include<iomanip>
#include <stdlib.h>
using namespace std;
double getTotal(double[], int);
double getHighest(double [], double);
double getLowest(double [], double);
double getAverage(double[], double);
int main () {
const int MONTHS = 12;
int months[MONTHS]= {"01", "02", "03", "04",
"05", "06", "07", "08",
"09", "10", "12"};
double rainfall[MONTHS];
for (int index = 0; index < MONTHS; index++)
{
cout << "Enter the rainfall (in inches for the months) ";
cout << months [index + 1]<<":";
//cin >> rainfall[index];
}
cout << "***Sumary" << endl;
cout << "Total rainfall: " << getTotal(rainfall ,12) << "inches"<< endl;
//count << "Average monthly rainfall: " << getAverage(rainfall , 12) <<endl;
system("pause");
return 0;
}
double getTotal(double rF[], int MONTHS)
{
double total = 0;
for (int index =0; index < MONTHS; index++)
total+=rF[index];
return total;
}
double getAverage (double rF[], double size)
{
double average = 0.0;
double total = 0;
double rainfall;
for(int index = 0; index < size; index++)
total += rF [index];
average =total / rainfall;
return average;
}
double getHighest(double rF[], double size)
{
double highest;
highest = rF[0];
for ( int index =1; index < size; index++)
{
if(rF[index] > highest)
highest = rF[index];
return highest;
}
}
double getLowest(double rF[], double size)
{
double lowest;
lowest = rF[0];
for (int index = 0; index < size; index++)
{
if(rF[index] < lowest )
lowest = rF[index];
return lowest;
}
}
```

*Edited 3 Years Ago by Nick Evan*: Fixed formatting