1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int getRainfallData(int [], string [], int);
int getRainfallData(int rainfall[], string monthName[], int MONTHS)
{
double totalRainfall = 0;
double averageRainfall = 0;
string wettest;
string dryest;
for (int a = 0 ; a < MONTHS ; a++)
{
cout << "Enter the amount of rainfall for " << monthName[MONTHS] << ": ";
cin >> rainfall[MONTHS];
}
for (int b = 0 ; b < MONTHS ; b++)
{
totalRainfall = totalRainfall + rainfall[MONTHS];
averageRainfall = totalRainfall / 12;
}
cout << "\n";
cout << "The total rainfall amount of rainfall is " << totalRainfall << endl;
cout << "The average ammount of rainfall is " << averageRainfall << endl;
return rainfall[MONTHS];
}
int main()
{
const int MONTHS = 12;
int rainfall[MONTHS];
string monthName[MONTHS] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
getRainfallData(rainfall, monthName, MONTHS);
cout << endl << "Press ENTER to exit...";
cin.clear();
cin.sync();
cin.get();
return 0;
}
|