I have a similar problem as GIZMO928 did in FEB 2015
The problem is:
Write a program that lets the user enter the total rainfall for each of 12 months into an array of doubles. The program should calculate and display the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest amounts.
Input Validation: Do not accept negative numbers for monthly rainfall figures.
The difference is I must break the code up into four functions:
double getTotal(double [ ], int);
double getAverage(double [ ], int);
double getLowest(double [ ], int, int&); //returns the lowest value, provides the index of the lowest value in the last parameter.
double getHighest(double [ ], int, int&); //returns the highest value, provides the index of the highest value in the last parameter.
When I write the program in one continuous main() function it works.
Then I try to break it up into functions and I get lost. This is what I have so far.
for (count = 1; count < MONTHS; count++)
{
if (rain[count] < lowest)
{
lowMonth = name[count];
lowest = rain[count];
}
}
return lowMonth, lowest;
}
Please help. I know it's a mess at this point bu I'm lost.