#include<iostream>
using namespace std;
int intro();
double getData();
double averageHigh();
double averageLow();
double indexHighTemp();
double indexLowTemp();
double table();
double i,j,hsum=0,lsum=0,aveh,avel,high=0,low=0,ind;
int const row=2,col=12,num=12;
double temp[row][col];
char month[20][num]={"JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"};
char space[]=" ";
int main()
{getData();
table();
averageHigh();
averageLow();
indexHighTemp();
indexLowTemp();
return 0;
}
int intro()
{
cout<<"||||| |||| ||||| |||| |||| |||| |||| || | | |||| ||| |||| "<<endl;
cout<<" | | | | | | | | | | | | | | | | | | | | "<<endl;
cout<<" | |||| | | | |||| | | |||| | | | | |||| ||||| ||| "<<endl;
cout<<" | | | | | | | | | | | | | | | | | "<<endl;
cout<<" | |||| | | | | |||| | |||| | |||| | | | |"<<endl;
return 0;
}
double getData()
{
for (i=0;i<col;i++)
{do
{intro();
cout<<endl<<"INPUT TEMPERATURES FOR THE FOLLOWING MONTHS."<<endl;
cout<<"(Highest temperature must be greater that lowest temperature)"<<endl<<endl<<endl;
cout<<(month[i])<<": ";
for (j=0;j<row;j++)
{if (j==0)
cout<<endl<<endl<<"Highest Temperature of the Month: ";
else
cout<<endl<<"Lowest Temperature of the Month: ";
cin>>(temp[j][i]);
}}
while ((temp[0][i])<(temp[1][i]));
}
return 0;
}
double averageHigh()
{for (i=0;i<col;i++)
{hsum=(hsum+(temp[0][i]));}
aveh=hsum/12;
cout<<endl<<"The Average High Temperature is: ";
cout<<aveh;
return 0;
}
double averageLow()
{for (i=0;i<col;i++)
{lsum=(lsum+(temp[1][i]));}
avel=lsum/12;
cout<<endl<<"The Average Low Temperature is: ";
cout<<avel;
return 0;
}
double indexHighTemp()
{ind=0;
for (i=0;i<col;i++)
{if (high<=(temp[0][i]))
{high=(temp[0][i]);
ind=i;
}
}
cout<<endl<<"The Highest Temperature of the Year is: ";
cout<<(temp[0][ind]);
return 0;
}
double indexLowTemp()
{ind=0;
for (i=0;i<col;i++)
{if (low>=(temp[1][i]))
{low=(temp[1][i]);
ind=i;
}
}
cout<<endl<<"The Lowest Temperature of the Year is: ";
cout<<(temp[1][ind]);
return 0;
}
double table()
{
intro();
cout<<" HIGHEST TEMPERATURE LOWEST TEMPERATURE"<<endl<<endl;
cout<<" JANUARY "<<temp[0][0]<<space<<temp[1][0]<<endl;
cout<<" FEBRUARY "<<temp[0][1]<<space<<temp[1][1]<<endl;
cout<<" MARCH "<<temp[0][2]<<space<<temp[1][2]<<endl;
cout<<" APRIL "<<temp[0][3]<<space<<temp[1][3]<<endl;
cout<<" MAY "<<temp[0][4]<<space<<temp[1][4]<<endl;
cout<<" JUNE "<<temp[0][5]<<space<<temp[1][5]<<endl;
cout<<" JULY "<<temp[0][6]<<space<<temp[1][6]<<endl;
cout<<" AUGUST "<<temp[0][7]<<space<<temp[1][7]<<endl;
cout<<" SEPTEMBER "<<temp[0][8]<<space<<temp[1][8]<<endl;
cout<<" OCTOBER "<<temp[0][9]<<space<<temp[1][9]<<endl;
cout<<" NOVEMBER "<<temp[0][10]<<space<<temp[1][10]<<endl;
cout<<" DECEMBER "<<temp[0][11]<<space<<temp[1][11]<<endl;
return 0;
}
c:\users\ethelbert karl\visual studio 2008\projects\coe050\coe050\arrays.cpp(45) : error C2108: subscript is not of integral type
c:\users\ethelbert karl\visual studio 2008\projects\coe050\coe050\arrays.cpp(51) : error C2108: subscript is not of integral type
c:\users\ethelbert karl\visual studio 2008\projects\coe050\coe050\arrays.cpp(53) : error C2108: subscript is not of integral type
c:\users\ethelbert karl\visual studio 2008\projects\coe050\coe050\arrays.cpp(53) : error C2108: subscript is not of integral type
c:\users\ethelbert karl\visual studio 2008\projects\coe050\coe050\arrays.cpp(60) : error C2108: subscript is not of integral type
c:\users\ethelbert karl\visual studio 2008\projects\coe050\coe050\arrays.cpp(69) : error C2108: subscript is not of integral type
c:\users\ethelbert karl\visual studio 2008\projects\coe050\coe050\arrays.cpp(79) : error C2108: subscript is not of integral type
c:\users\ethelbert karl\visual studio 2008\projects\coe050\coe050\arrays.cpp(80) : error C2108: subscript is not of integral type
c:\users\ethelbert karl\visual studio 2008\projects\coe050\coe050\arrays.cpp(85) : error C2108: subscript is not of integral type
c:\users\ethelbert karl\visual studio 2008\projects\coe050\coe050\arrays.cpp(92) : error C2108: subscript is not of integral type
c:\users\ethelbert karl\visual studio 2008\projects\coe050\coe050\arrays.cpp(93) : error C2108: subscript is not of integral type
c:\users\ethelbert karl\visual studio 2008\projects\coe050\coe050\arrays.cpp(98) : error C2108: subscript is not of integral type
Build log was saved at "file://c:\Users\Ethelbert Karl\Visual Studio 2008\Projects\COE050\COE050\Debug\BuildLog.htm"
COE050 - 12 error(s), 0 warning(s)
i dont know why this error occurs....
please tell me whats the problem with my code