im getting an error cannot convert 'int' to 'double' for argument '1' to 'double sort Array(double'.int)' while trying to debug code
what does that mean here is another copy of my code now.
#include <iostream>
#include <iomanip>
using namespace std;
// Function prototypes
double sumArray(double[], int);
double getHighest(double[], int);
double getLowest(double[], int);
double sortArray(double [], int);
double showArray(double [], int);
int main()
{
const int MONTHS = 12;
int values[MONTHS] = {12, 11, 10, 9, 8, 7, 6,
5, 4, 3, 2, 1};
double amount[MONTHS] = {12, 34, 3, 6, 5, 7, 4, 44, 43, 40, 41, 9 };
double 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 << " inches" << endl;
cout << "The average monthly rainfall is " << average << " inches" << endl;
cout << "The highest monthly rainfall is " << highest << " inches" << endl;
cout << "The lowest monthly rainfall is " << lowest << " inches " << endl;
cout << "The monthly rainfall in descending order:\n";
sortArray(values, MONTHS);
showArray(values, MONTHS);
return 0;
}
//******************************************************************
// 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 getHighest(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;
}
//*******************************************************************
// Definition of function sortArray *
// This function performs an descending order buble sort on *
// array. elems is the number of elements in the array. *
//*******************************************************************
void sortArray(int array[], int elems)
{
bool swap;
int temp;
do
{
swap = false;
for (int count = 0; count < (elems - 1); count++)
{
if (array[count] > array[count + 1])
{
temp = array[count];
array[count] = array[count + 1];
array[count + 1] = temp;
swap = true;
}
}
} while (swap);
}
//********************************************************************
// Definition of function showArray. *
// This function displays the contents of array. elems is the *
// number of elements. *
//********************************************************************
void showArray(int array[], int elems)
{
for (int count = 0; count < elems; count++)
cout << array[count] << " ";
cout << endl;
}