Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a modular program that analyzes a year\'s worth of rainfall data. In addit

ID: 3634272 • Letter: W

Question

Write a modular program that analyzes a year's worth of rainfall data. In addition to main, the program should have a getData function that accepts the total rainfall for each of 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. These last two functions return the number of the month with the lowest and highest rainfall amounts, not the amount of rain that fell those months. Notice that this month number can be used to obtain the amount of rain that fell those months. Input validation: Do not accept rainfall amounts less than 0. This information should be used either by main or by a displayReport function called by main to print a summary rainfall report similar to the following:

Explanation / Answer

please rate - thanks

# include <iostream>
using namespace std;
double GetTotal(double[],int);
double GetLargest(double[],int);
double GetAverage(double,int);
double GetSmallest(double[],int);
int main ()
{int i,numbers=12;
double rain[numbers],tot;
for(i=0;i<numbers;i++)
   {cout<<"Enter the rain for month "<<i+1<<": ";
   cin>>rain[i];
   while(rain[i]<0)
       {cout<<"must be >=0 ";
         cout<<"Enter the rain for month "<<i+1<<": ";
        cin>>rain[i];
        }
   }
tot=GetTotal(rain,numbers);
cout<<"The total rainfall for the year is: "<<tot<<" inches ";
cout<<"The average monthly rainfall is: "<<GetAverage(tot,numbers)<<" inches ";
cout<<"The most rainfall in a month is: "<<GetLargest(rain,numbers)<<" inches ";
cout<<"The least rainfall in a month is: "<<GetSmallest(rain,numbers)<<" inches ";
system("pause");
return 0;
}

double GetTotal(double r[],int n)
{int i;
double val=0;
for(i=0;i<n;i++)
   val+=r[i];
return val;
}
double GetLargest(double r[],int n)
{int i;
double val=0;
val=r[0];
for(i=1;i<n;i++)
   if(r[i]>val)
      val=r[i];
return val;
}
double GetAverage(double t,int n)
{return t/n;
}
double GetSmallest(double r[],int n)
{int i;
double val=0;
val=r[0];
for(i=1;i<n;i++)
   if(r[i]<val)
      val=r[i];
return val;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote