For you function, try structuring it to return a string, and display that return value, like so:
CODE
#include <iostream>
#include <string>
using namespace std;
int getActualRain(int j);
string print_month(int month);
//char January, February;
int main()
{
int i;
float AverageRain[13];
float ActualRain[13];
for (i = 1; i < 13; i++)
{
cout << "Enter average Monthly Rainfall for " << print_month(i) << ": ";
cin >> AverageRain[i];
}
int month;
cout << "Please enter current month: " << endl;
cin >> month;
getch();
return 0;
}
string print_month(int month)
{
string result;
switch (month)
{
case 1:
result = "January";
break;
case 2:
result = "February";
break;
case 3:
result = "March";
break;
case 4:
result = "April";
break;
case 5:
result = "May";
break;
case 6:
result = "June";
break;
case 7:
result = "July";
break;
case 8:
result = "August";
break;
case 9:
result = "September";
break;
case 10:
result = "October";
break;
case 11:
result = "November";
break;
case 12:
result = "December";
break;
default:
cout << "Invalid Value!\a";
break;
}
return result;
}
AS for the second part of your code, you are currently telling the compiler to compare two variables, one named month, the other named January (or Feb, etc...). You are also using the assignment operator, not the equality operator. If you are trying to compare strings, it should look as follows:
CODE
if ( month == "January" )
Please note that I have not cleaned up the code, or optimized, simply pointed out a few areas in which errors are occurring. this is not meant to be copied and pasted, but used as a reference.