#include <iostream>
usingnamespace std;
int main()
{
constint SIZE = 12; // Constant for array size
int values[SIZE]; // Array to hold values
int index = 0;
// Get the values.
for (; index < SIZE; index++)
{
cout << "Enter the amount of rainfall for month "
<< index + 1 << ": ";
cin >> values[index];
}
double total = 0;
// Step through that array, adding each element to
// the accumulator.
for (int index = 0; index < SIZE; index++)
{
total += values[index];
}
//Display the total.
cout << "The total amount of rainfall is " << total << endl;
double average;
// Calculate the average.
average = total / SIZE;
// Display the average.
cout << "The average rainfall is " << average << endl;
double highest = values[0];
// Step trough the rest of the array, beginning at
// element 1. When a value greater than highest is found,
// assign that value to highest.
for (int index = 0; index < SIZE; index++)
{
if (values[index] > highest)
{
highest = values[index];
}
}
// Display the highest value.
cout << "The highest amount of rainfall is " << highest << endl;
double lowest = values[0];
// Step through the rest of the array, beginning at
// element 1. When a value less than lowest is found,
// assign that value to lowest.
for (int index = 0; index < SIZE; index++)
{
if (values[index] < lowest)
{
lowest = values[index];
}
}
// Display the lowest value.
cout << "The lowest amount of rainfall is " << lowest << endl;
return 0;
}