Ok, i have program written to find the total amount of rainfall, the average , the highsest and lowest. Now i am compiling it and im getting a expected unqualified-id before token '{' token error message? can anyone look at my code and see why im getting this error its probably really simple but i can see it.
Thanks in advance.
Code:
#include <iostream>
#include <iomanip>
using namespace std;
// Function prototypes
double sumArray(double[], int);
double getHighest(double[], int);
double getLowest(double[], int);
int main()
{
const int MONTHS = 12;
double amount[MONTHS], // To hold the amount of rainfall
total, // To hold the total rainfall
average, // To hold the average rainfall
highest, // To hold the highest rainfall amount
lowest; // To hold the lowest rainfall amount
cout << "Enter the rainfall for each month.\n";
for (int count = 0; count < MONTHS; count++)
{
cout << "Month " << (count + 1) << ": ";
cin >> amount[count];
}
// Get the total monthly rainfall
total = sumArray(amount, MONTHS);
// Calculate the average rainfall
average = total / MONTHS;
// Find the highest monthly rainfall
highest = getHighest(amount, MONTHS);
// Find the lowest monthly rainfall
lowest = getLowest(amount, MONTHS);
// Display the results
cout << fixed << showpoint << setprecision(2);
cout << "The total monthly rainfall is" << total << endl;
cout << "The average monthly rainfall is" << average << endl;
cout << "The highest montthly rainfall is" << highest << endl;
cout << "The lowest monthly rainfall is" << lowest << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
//******************************************************************
// Definition of sumArray *
// This function accepts a double array and its size *
// as arguments. The sum of the array's elements *
// is returned as an double. *
//******************************************************************
double sumArray(double array[], int size)
{
double total = 0;
for (int count = 0; count < size; count++)
total += array[count];
return total;
}
//******************************************************************
// Definition of getHighest *
// This function accepts a double array and its size *
// as arguments. The highest value in the array is *
// returned as an double. *
//******************************************************************
double getHightest(double array[], int size)
{
double highest;
highest = array[0];
for (int count = 1; count < size; count++)
{
if (array[count] > highest)
highest = array[count];
}
return highest;
}
//*******************************************************************
// Definition of getLowest *
// This function accepts a double array and its size *
// as arguments. The lowest value in the array is *
// returned as an double *
//*******************************************************************
double getLowest(double array[], int size);
{
double lowest;
lowest = array[0];
for (int count = 1; count < size; count++)
{
if (array[count] < lowest)
lowest = array[count];
}
return lowest;
}