const int ARRAYSIZE=12;
int main()
{
int rain[ARRAYSIZE];
double sum, average, stddev;
int min=0;
ifstream infile;
TellUser();//tell user what program does
infile.open("C:\\rainfall.txt");
if (infile.fail())
cout <<"Bad file" << endl;
else
{
getRain(infile, rain); //read input file & populate array
sum = calc_Total_Rain(rain);
cout << "The total rainfall for the year is: " << sum << endl;
min = computeMin(rain);
cout << "The minimum rainfall for the year is: " << min << endl;
average = find_AveRainfall(rain);
cout << "Average rainfall= " << average << endl;
Question 1
Write the missing code to compute the function getRainfall(), that reads in the
twelve values from the file rainfall.txt and stores it in the array rain.
rainfall.txt
12, 30, 10, 5, 17, 15, 22, 12, 11, 16, 0, 21
---
void getRainfall(ifstream &infile, int rain)
{
xxxxx
}
Question 2
write the missing code to complete the function calc-Total_Rain(), that sums up
the twelve values stored in the array rain
double calc_Total_Rain(int rain[]){
xxxxxxx
}
Question 3
Write the missing code to complete the function computeMin() that finds the minimum value that stored in the array rain