|
From: Shawn <tre...@gm...> - 2008-02-29 15:46:07
|
I've never tried using arrays before in C++, just am familiar with using
them in python. I tried initializing the array as string months and
then {"January","February", ect} but the complier told me I needed to
set it up in constructor method. I looked that up in my book and came
up with this, but now I get the error that January isn't declared.
My intention is to have it automatically advance to the next month in
the list by months[i] in the inner loop. Am I on the right track?
Thanks!
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
int years = 0;
int counter = 0;
int month = 0;
int average = 0;
*class months =
{January,February,March,April,May,June,July,August,September,October,November,December};*
months++
cout<<"Please enter the # of years.">>endl;
for(i=years; i<=years; i++1)
{
for(i=12; i<=12; i++1)
{cout<<"Please enter the rainfall for"<<months[i]<<;
cin>>month
sum = sum + month
counter = counter + 1
}
average = sum / counter
cout<<"The total number of months was "<<counter<<".";
cout<<"The total inches of rainfall was "<<sum<<".";
cout<<"The average rainfall was "<<average<<".";
return 0;
}
|