Answer:
#include<iostream>
#include <iomanip>
using namespace std;
const int NUM_MONTHS = 12;
double getTotal(double [], int);
double getAverage(double [], int);
double getLargest(double [], int, int &);
double getSmallest(double [], int, int &);
double getTotal(int rainFall,double NUM_MONTHS[])
{
double total = 0;
for (int count = 0; count < NUM_MONTH; count++)
total += NUM_MONTH[count];
return total;
}
double getAverage(int rainFall,double NUM_MONTH[])
{getTotal(rainFall,NUM_MONTH)
average= total/NUM_MONTHS;
return average;
}
double getHighest(int rainFall, double NUM_MONTHS[]) //I left out the subScript peice as I was not sure how to procede with that;
{
double largest;
largest = NUM_MONTHS[0];
for ( int month = 1; month <= NUM_MONTHS; month++ ){
if ( values[month] > largest ){
largest = values[month];
return largest;
}
double getSmallest(int rainFall, double NUM_MONTHS[])
{
double smallest;
smallest = NUM_MONTHS[0];
for ( int month = 1; month <= NUM_MONTHS; month){
if ( values[month] < smallest ){
smallest = values[month];
return smallest;
}
int main()
{
double rainFall[NUM_MONTHS];
for (int month = 0; month < NUM_MONTHS; month++)
{
cout << "Enter the rainfall (in inches) for month #";
cout << (month + 1) << ": ";
cin >> rainFall[month];
while (rainFall[month] < 0)
{
cout << "Rainfall must be 0 or more.\n"
<< "Please re-enter: ";
cin >> rainFall[month];
}
}
cout << fixed << showpoint << setprecision(2) << endl;
cout << "The total rainfall for the year is ";
cout << getTotal(rainFall, NUM_MONTHS)
<< " inches." << endl;
cout << "The average rainfall for the year is ";
cout << getAverage(rainFall, NUM_MONTHS)
<< " inches." << endl;
int subScript;
cout << "The largest amount of rainfall was ";
cout << getLargest(rainFall, NUM_MONTHS, subScript)
<< " inches in month ";
cout << (subScript + 1) << "." << endl;
cout << "The smallest amount of rainfall was ";
cout << getSmallest(rainFall, NUM_MONTHS, subScript)
<< " inches in month ";
cout << (subScript + 1) << "." << endl << endl;
return 0;
}