Need a prg that lets user enter total rainfall for each of 12 months into an array of doubles,prg should then calculate and display total rainfall for year,the average monthly rainfall, and the months with highest and lowest amounts
need to use four functions
double getTotal(double[],int);//calculates adn returns total of the values stored in the array parameter;the size parameter indicates the number of elements in the array
double getAverage(doube[],int); //returns the average of the values in the array parameter;the size parameter indicates the number of elements in the array
double getLargest(double[],int,int &);//returns the smallest value in the array parameter and stores the subscript of the largest value in the element reference parameter
double getSmallest(double[],int,int &);//returns the smallest value in the array parameter and stores the subscript of the smallest value in the element reference parameter
this is what i have but im struggling with arrays and functions please help i know its wrong but i dont know what to fix or even if im on right track
#include
#include
using namespace std;
double getTotal(double array[],int monthTotalRain)
{
string months[]={"January","February","March","April","May","June","July","August","September",
"October","November","December"};
double monthTotalRain[12];
double totalRainFall=0;
for(int count=0;count<=11;count++)
{
cout<<"What is total rainfall for every month? "< cout< cin>>monthTotalRain[count];
totalRainFall+=monthTotalRain;
}
while monthTotalRain<0)
{
cout<<"Please re-enter amount above zero: ";
cin>>monthTotalRain;
totalRainFall+=monthTotalRain;
}
cout<<"The total amount of rainfall for the year is: "< return totalRainFall;
}
double getAverage(double array[],int size)
{
double average;
average=getTotal[]/size;
return average;
}
double getLargest(double array[],int size,int &largest)
{
double highest;
highest=array[0];
for(int count=0;count {
if array[count]>highest)
highest=array[count];
}
return highest;
double getSmallest(double array[],int size,int &smallest)
{
double lowest;
lowest=array[0];
for(int count=1;count {
if array[count] lowest=array[count];
}
return lowest;
}
int main()
{
const int rain=12;
double rainfall[rain];
double totalRainYr=0;
double averageRain;
string highMonth;
string lowMonth;
double highestRain;
double highest=0;
double lowest=0;
double lowestRain;
double total;
double average;
total=getTotal(rainfall,rain);
average=getAverage(rainfall,rain);
highestRain=getLargest(rainfall,rain,highest);
lowestRain= getSmallest(rainfall,rain,lowest);
cout<<"The lowest amount of rain is "< cout<<"The highest amount of rain is "<
return 0;
}