okay well this program basically infiles grades and then find the highest, lowest and average. Then it's supposed to find how many grades are within the 50-59, 60-69, 70-79, 80-89, and 90-100 range. I am having trouble keeping track of how many numbers within the first array fall into those categories. This is the code I have so far:
//Christian Herrera
//Programming Fundamentals I
//05-10-13
//Final Exam
#include<iostream>
#include<iomanip>
#include<string>
#include<fstream>
using namespace std;
int highest(int[], int);
int lowest(int[], int size);
double average(int[],int);
void gradeDistribution(int[]&,int);
int main()
{
const int SIZE=20;
int grades[SIZE];
ifstream infile;
infile.open("values.txt");
for (int x=0; x<20; x++)
{
infile>>grades[x];
}
infile.close();
cout<<"The highest grade is: "<<highest(grades, SIZE)<<endl;
cout<<"The lowest grade is: "<<lowest(grades, SIZE)<<endl;
cout<<"The average grade is: "<<fixed<<showpoint<<setprecision(1)<<average(grades, SIZE)<<endl;
gradeDistribution(grades&, SIZE);
system("pause");
return 0;
}
int lowest(int grades[],int size)
{
int lowest=grades[0];
for(int count=1; count<size; count++)
{
if(grades[count]<lowest)
lowest=grades[count];
}
return lowest;
}
int highest(int grades[],int size)
{
int highest=grades[0];
for(int count=1; count<size; count++)
{
if(grades[count]>highest)
highest=grades[count];
}
The problem is that when I cout the array in the gradeDistribution function, the numbers I'm supposed to get don't come up. Something is probably wrong with my counters. For every grade that is between 50-59 it needs to count them and put the final "total" in the first location of the array. In this case distribution[0]. In this function it has to read all the numbers from my grades[] array and count which ones fall into what category then place the amounts in the distribution[] array