C
C++Geek
IfIf anyone can help with this I would greatly appreciate it. I have
written the following code but get an error message that reads "term
does not evaluate to a function". The errors are on lines 36 & 37.
Thank you
#include <iostream>
#include <iomanip>
const int stu_num = 10, quiz_num = 8;
void st_ave(const int grade[][quiz_num], double st_ave[]);
void quiz_ave(const int grade[][quiz_num], double quiz_ave[]);
void display(const int grade[][quiz_num],
const double st_ave[], const double
quiz_ave[]);
int main( )
{
using namespace std;
int grade[stu_num][quiz_num];
double st_ave[stu_num];
double quiz_ave[quiz_num];
for(int i=0; i< stu_num; i++)
{
cout<<"enter grades for students"<<i+1;
for(int j=0; j <quiz_num; j++)
cin>>grade[j];
}
st_ave(grade, st_ave);
quiz_ave(grade, quiz_ave);
display(grade, st_ave, quiz_ave);
return 0;
}
void st_ave(const int grade[][quiz_num], double st_ave[])
{
for (int st = 1; st <= stu_num; st++)
{
double sum = 0;
for (int qu = 1; qu <= quiz_num; qu++)
sum = sum + grade[st-1][qu-1];
st_ave[st-1] = sum/quiz_num;
}
}
void quiz_ave(const int grade[][quiz_num], double quiz_ave[])
{
for (int qu= 1; qu <= quiz_num; qu++)
{
double sum = 0;
for (int st = 1; st <= stu_num; st++)
sum = sum + grade[st-1][qu-1];
quiz_ave[qu-1] = sum/stu_num;
}
}
//Uses iostream and iomanip:
void display(const int grade[][quiz_num],
const double st_ave[], const double
quiz_ave[])
{
using namespace std;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(1);
cout << setw(10) << "Student"
<< setw(5) << "Ave"
<< setw(15) << "Quizzes\n";
for (int st = 1; st <= stu_num; st++)
{
cout << setw(10) << st
<< setw(5) << st_ave[st-1] << " ";
for (int qu = 1; qu <= quiz_num; qu++)
cout << setw(5) << grade[st-1][qu-1];
cout << endl;
}
cout << "Quiz averages = ";
for (int qu = 1; qu <= quiz_num; qu++)
cout << setw(5) << quiz_ave[qu-1];
cout << endl;
}
written the following code but get an error message that reads "term
does not evaluate to a function". The errors are on lines 36 & 37.
Thank you
#include <iostream>
#include <iomanip>
const int stu_num = 10, quiz_num = 8;
void st_ave(const int grade[][quiz_num], double st_ave[]);
void quiz_ave(const int grade[][quiz_num], double quiz_ave[]);
void display(const int grade[][quiz_num],
const double st_ave[], const double
quiz_ave[]);
int main( )
{
using namespace std;
int grade[stu_num][quiz_num];
double st_ave[stu_num];
double quiz_ave[quiz_num];
for(int i=0; i< stu_num; i++)
{
cout<<"enter grades for students"<<i+1;
for(int j=0; j <quiz_num; j++)
cin>>grade[j];
}
st_ave(grade, st_ave);
quiz_ave(grade, quiz_ave);
display(grade, st_ave, quiz_ave);
return 0;
}
void st_ave(const int grade[][quiz_num], double st_ave[])
{
for (int st = 1; st <= stu_num; st++)
{
double sum = 0;
for (int qu = 1; qu <= quiz_num; qu++)
sum = sum + grade[st-1][qu-1];
st_ave[st-1] = sum/quiz_num;
}
}
void quiz_ave(const int grade[][quiz_num], double quiz_ave[])
{
for (int qu= 1; qu <= quiz_num; qu++)
{
double sum = 0;
for (int st = 1; st <= stu_num; st++)
sum = sum + grade[st-1][qu-1];
quiz_ave[qu-1] = sum/stu_num;
}
}
//Uses iostream and iomanip:
void display(const int grade[][quiz_num],
const double st_ave[], const double
quiz_ave[])
{
using namespace std;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(1);
cout << setw(10) << "Student"
<< setw(5) << "Ave"
<< setw(15) << "Quizzes\n";
for (int st = 1; st <= stu_num; st++)
{
cout << setw(10) << st
<< setw(5) << st_ave[st-1] << " ";
for (int qu = 1; qu <= quiz_num; qu++)
cout << setw(5) << grade[st-1][qu-1];
cout << endl;
}
cout << "Quiz averages = ";
for (int qu = 1; qu <= quiz_num; qu++)
cout << setw(5) << quiz_ave[qu-1];
cout << endl;
}