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 49 50 51
|
#include <iostream>
#include <conio.h>
#include <string>
#include <iomanip>
using namespace std;
struct weather
{
double rainfall;
double high_temp;
double low_temp;
double avg_temp;
}
;
enum Month { January, Februaury, March, April, May,
June, July, August, September, October, November
, December};
int main()
{
const int NUM_MONTHS = 12; // Number of months
weather months[NUM_MONTHS];
int i;
double yearlyRain = 0.0, avgRain;
enum Month { Janurauy, Februaury, March, April, May,
June, July, August, September, October, November
, December};
Month rainMonth;
for (rainMonth = January; rainMonth <= December;
rainMonth = static_cast<Month>(rainMonth +1))
/*int i = 0; i < NUM_MONTHS; i++)*/
{
cout << "Please enter the rainfall inches of month ";
cout << (i + 1) << " :";
cin >> months[i].rainfall;
yearlyRain += months[i].rainfall;
avgRain = yearlyRain/12;
}
cout << "The total rainfall for the year is: "
<< yearlyRain << " inches" << endl;
//Avg rain for the year
cout << "The average rainfall fpr the year is ";
cout << yearlyRain << " inches" << endl;
_getch();
}
|