help me to find the lowest average through find_lowest() function.

//i had found the highest average mark through find_highest() function.
//i use the same method to find the lowest average mark , but the answer that i //got is 0.00, not the answer that i want.
//so ,how to solve this problem??


#include<iostream>
#include<iomanip>
using namespace std;
#define n 10

double find_average(double );
void find_highest(double , double &);
void find_lowest(double , double &);
void display_grade();
const int No_matric=10;
const int matricNo=7;
const int row_Scores=10;
const int col_Scores=3;
double average,total,highest,lowest;
int row;


char noMatrix[No_matric][matricNo] ={"BC0123","BC1234","BC2345","BC3456","BC4567","BC5678","BC6789","BC7890","BC8900","BC9999"};
double scores[row_Scores][col_Scores]={{84.2,86.4,79.8},{93.2,87.4,65.4},{86.0,83.5,84.5},{30.0,50.5,80.2},{54.9,78.8,90.3},
{45.7,63.8,50.2},{78.4,47.6,68.7},{88.8,73.2,87.6},{78.7,40.3,59.6},{67.9,77.8,90.1}};
int main()
{




cout<<"\tBITP1113 : Students' Performance Report"<<endl;
cout<<"\t---------------------------------------"<<endl;
cout<<" Matric no.\tTest1\tTest2\tTest3\tAverage"<<" "<<"Grade"<<endl;
cout<<" ---------\t-----\t-----\t-----\t-------"<<" "<<"-----"<<endl;


for(row=0; row<10;row++)
{
cout<<"\n"" "<<noMatrix[row];

for(int col=0;col<3;col++)
{
cout<<"\t"<<setprecision(2)<<fixed<<scores[row][col];
}

average = find_average(average);
cout<<setprecision(2)<<fixed<<" \t "<<average<<"\t ";
display_grade();
find_highest(average,highest);
find_lowest(average,lowest);

}

cout<<endl<<endl<<endl;
cout<<" ""BITP1113 : Students' Performance Analysis Report"<<endl;
cout<<" ""------------------------------------------------"<<endl;
cout<<"\t\tHighest average mark = ";
cout<<highest;

cout<<endl;
cout<<"\t\tLowest average mark = ";
cout<<lowest<<endl;
return 0;
}


double find_average(double average)
{
{
double total;
total =scores[row][0]+scores[row][1]+scores[row][2];
average= total/3;
}
return average;


}

void display_grade()
{
if(average>=80 && average<=100)
cout<<" A"<<endl;

else if (average>=70 && average<=79.9)
cout<<" B"<<endl;

else if(average>=60 && average<=69.9)
cout<<" C"<<endl;

else if (average>=40 && average<=59.9)
cout<<" D"<<endl;

else
cout<<" E"<<endl;
}


void find_highest(double average, double &highest)
{
if (average>highest)
highest=average;

}


void find_lowest(double average, double &lowest)
{
if (average<lowest)
lowest=average;

}
I would love to help you but my brain is too fried from finals to navigate through this godawful code.

If you put it the code brackets it makes it much easier for others to read. Sorry I couldn't help.



Last edited on
Topic archived. No new replies allowed.