I need help with my output. I have pretty much everything done. I'm just getting an output like:
"The class average is 5.8%"
"The class average is 12.4%"
"The class average is 13.6%"
"The class average is 18.4%"
etc.
"Highest grade is 58%"
"Highest grade is 66%"
"Highest grade is 85%"
"Highest grade is 96%"
etc.
"0 out of 10 passed the test"
"2 out of 10 passed the test"
"4 out of 10 passed the test"
etc.
I want to end with the last class average (ex: 18.4%), the last highest grade (ex: 96%) and the greatest number of students who passed the text (ex: 4 out of 10 passed the test).
One other thing I need help with....I believe I did everything right, but I need "getMax" and "countPassing" functions to have "value returning"....I don't know how to do "value returning", so I need help with that.
Here is my code:
#include <iostream>
#include <iomanip>
using namespace std;
const int numofgrades = 10;
void getGrades(double grades[]);
double computeAverage(double grades[]);
double getMax(double grades[]);
void countPassing(double grades[]);
int main ()
{
double grades[numofgrades];
double avg;
double largest;
getGrades(grades);
computeAverage(grades);
getMax(grades);
countPassing(grades);
system ("PAUSE");
return 0;
}
void getGrades(double grades[])
{
cout<<"Please enter 10 grades"<<endl;
cout<<""<<endl;
for (int i=0; i<numofgrades; i++)
{
cout<<"Grade #"<<(i+1)<<endl;
cin>>grades[i];
}
}
double computeAverage(double grades[])
{
double avg;
double sum = 0;
for (int i=0; i<10; i++)
{
sum+=grades[i];
avg = (sum/10);
cout<<"The class average is "<<avg<<"%"<<endl;
}
}
double getMax(double grades[])
{
double largest = grades[0];
for (int i=0; i<numofgrades; i++)
{
if (grades[i] > largest)
largest = grades[i];
cout<<"Highest grade is "<<largest<<"%"<<endl;
}
}
void countPassing(double grades[])
{
double sum = 0;
for (int i=0; i<numofgrades; i++)
{
sum+=grades[i];
if (grades[i] > 59)
i++;
cout<<(i++)<<"out of "<<numofgrades<<" passed the test"<<endl;
}
}