Total rainfall program error check; Did I write the code correctly?

I've developed a program (with the help of other post from in other forums on this site) to take the rainfall for the 12 months in a year and calculate the total, average, lowest month and highest month. My questions is did I meet all the requirements that I will post at the beginning of my code? I have a very vague understanding of arrays and array size.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
  /* This program lets the user enter the total rainfall for each of 12 months into and array of doubles.
The program should use two 12-element arrays.  One array will hold strings, the names of the 12 months.  This array will
be initialized when the array is created using and initialization list (could also be created as an array of constants).
The second array will hold doubles which will be the total rainfall for each month (using both arrays) and store the
value entered into the array with the rainfall totals; the other is used to display which month the program is asking for the rainfall total.
The program should dispaly the following once the data is all entered:  total rainfall for the year, the average monthly rainfall,
the month with the highest amount of rainfall (must display the month as a string), and
the month with the lowest amount of rainfall (must display the month as a string).

The program must have the following functions: getTotal, getAverage, getLowest (returns the lowest value, provides the index of the lowest value
in the last parameter), getHighest (returns the highest value, provides the index of the highest value in the last parameter.  
*/

#include <iostream>
#include <string>

using namespace std;

const int NUM_MONTHS = 12;
const int STRING_SIZE = 10;

//  Function Prototypes 
void getTotal(double[]);
void getAverage(double[]);
void getLowest(double[], char[][STRING_SIZE]);
void getHighest(double[], char[][STRING_SIZE]);
void zeroArray(string[]);

int main()
{
	double rain[NUM_MONTHS];
	int count;
	char months[NUM_MONTHS][STRING_SIZE] =
	{ "January", "February", "March",
		"April", "May", "June", "July",
		"August", "September", "October",
		"November", "December" };
	for (count = 0; count < NUM_MONTHS; count++)
	{
		cout << "Enter the rainfall for the month of ";
		cout << months[count] << " in inches: ";
		cin >> rain[count];
			while (rain[count] < 0)
		{
			cout << "Invaliad entery. Please enter a number greater than or equal to 0:\n";
			cin >> rain[count];
		}
	}
	cout << "\n Annual Rainfall Report:\n\n";
	getTotal(rain);
	getAverage(rain);
	getLowest(rain, months);
	getHighest(rain, months);
	return 0;
}
// Calculate total rainfall 
void getTotal(double rain[])
{
	double total = 0;
	for (int index = 0; index < NUM_MONTHS; index++)
		total += rain[index];
	cout << "Total Rainfall: " << total << " inches.\n\n";
}
// Calcultate Average rainfall
void getAverage(double rain[])
{
	int count = 0;
	double avgRain = 0;
	double rainSum = 0;
	for (count = 0; count <= 11; count++)
	{
		rainSum = rainSum + rain[count];
	}
	avgRain = rainSum / 12;
	cout << "Average Rainfall: " << avgRain << " inches. \n\n";
}
// zeroArray function used for calculating lowest and highest ammounts.
void zeroArray(string arr[])
{
	for (int i = 0; i < 12; ++i)
		arr[i] = "";
}
// Calculate month with lowest rainfall amount.
void getLowest(double rain[], char months[][STRING_SIZE])
{
	string month[12];
	zeroArray(month);
	double lowest = rain[0];
	month[0] = months[0];
	for (int i = 1; i < 12; ++i)
	{
		if (rain[i] < lowest) {
			zeroArray(month);
			month[i] = months[i];
			lowest = rain[i];
		}
		else if (rain[i] == lowest)
		{
			month[i] = months[i];
		}
	}
	cout << "Lowest Rainfall: " << lowest << " inches" << endl;
	for (int i = 0; i < 12; ++i)
	{
		if (month[i] != "")
			cout << "Month with lowest rainfall: " << month[i] << endl;
	}
	cout << endl;
}
// Calculate month with highest rainfall amount.
void getHighest(double rain[], char months[][STRING_SIZE])
{
	string month[12];
	zeroArray(month);
	double highest = rain[0];
	month[0] = months[0];
		for (int i = 1; i < 12; ++i)
	{
		if (rain[i] > highest) 
		{
			zeroArray(month);
			month[i] = months[i];
			highest = rain[i];
		}
		else if (rain[i] == highest)
		{
			month[i] = months[i];
		}
	}
	cout << "Highest Rainfall: " << highest << " inches.\n";
	for (int i = 0; i < 12; ++i) 
	{
		if (month[i] != "")
			cout << "Month with highest rainfall: " << month[i] << endl;
	}
	cout << endl;
}
I just skimmed through the code (didn't try to compile or run it).

Comments - none of your functions return anything. Now that may be fair enough. However the comment at the top of the code states that getLowest and getHighest should definitely return a value, or at least use the last parameter to return the index of the month with the highest or lowest rainfall.

One might also expect the function getTotal to return a value, then it could be used by function getAverage rather than duplicating effort by finding the total all over again. Also, taking a hint from the names of these functions, one might expect a function named getSomething to return a value, rather than instead displaySomething.

So, my comments really are not about whether or not the code works, but as to whether it does what was asked for.

My suggestion is that you might put the cout statements for the results inside main() rather than distributed over all of the other functions.

I should add a 'well done' for attempting to handle the situation where more than one month may have the same rainfall, which is seemingly better than what was asked for. I'm not sure whether you might have to forgo this if you instead just return a single index value from the getLowest and getHighest functions.
OK, valid points, reading them like this makes perfect sense. I didn't think I had done what was actually ask of me, but the end result is what the assignment ask for. I will re-work the code, and hopefully not not loose more ground than I make and try your suggestions. Thanks for the input.
Topic archived. No new replies allowed.