//***********************************************************
// This function asks the user for the information of *
// amount of rain, highest temp. and lowest temp. it also *
// calculates the average temp. *
//***********************************************************
void statInfo()
{
for (int i=0; i<=INDEX; i++)
{
cout << "Data for " << Month[i] << ":" << endl; [b][b] //HERE IS THE ERROR in green (Thread1: EXC_BAD_ACCESS (code=1, address 0xffffffffffffffffffffe9)
cout << "Rainfall (mm):";
cin >> data[i].rainfall;
cout << "High Temperature (F): ";
cin >> data[i].highTemp;
cout << "Low Temperature (F): ";
cin >> data[i].lowTemp;
data[i].avgTemp = data[i].highTemp/data[i].lowTemp;
cout << endl;
}
}
//***********************************************************
// This function calculates the average rain for the year *
//***********************************************************
void rainAverage()
{
double rainAvg=0;
for (int i=0; i<=INDEX; i++)
{
rainAvg += data[i].rainfall;
}
rainAvg=rainAvg/INDEX;
cout << "The average rainfall for the year has been: " << rainAvg << "mm";
}
//***********************************************************
// This function calculates the highest temperature for the *
// year and the month in which it took place *
//***********************************************************
void highestTemperature()
{
int highestTemp=0;
string highestMonth;
for (int i=0; i<=INDEX; i++)
{
if (data[i].highTemp>highestTemp)
{
highestTemp=data[i].highTemp;
highestMonth=Month[i];
}
}
cout << "Highest Temperature of the year: " << highestMonth << " - " << highestTemp << "F";
}
//***********************************************************
// This function calculates the highest temperature for the *
// year and the month in which it took place *
//***********************************************************
void lowestTemperature()
{
int lowestTemp=141;
string lowestMonth;
for (int i=0; i<=INDEX; i++)
{
if (data[i].highTemp<lowestTemp)
{
lowestTemp=data[i].highTemp;
lowestMonth=Month[i];
}
}
cout << "Highest Temperature of the year: " << lowestMonth << " - " << lowestTemp << "F";
}
//******************************************************************
// This function calculates the average temperature for the year *
//******************************************************************
void temperatureAverage()
{
double tempAvg=0;
for (int i=0; i<=INDEX; i++)
{
tempAvg += data[i].avgTemp;
}
tempAvg=tempAvg/INDEX;
cout << "Average temperature for the year: " << tempAvg << "F";
}