Please Help, I have our first assignment here on functions. It is pretty difficult, at least the one part that I keep getting stuck on. I seemed to manuver through the other parts I was having trouble with so far. But to start our assignment is to write a program that will read in an unknown number (not more than 60) of test grades from a text file. the program is to calculate and output the following:
1.Number of test grades
2.Average of the Test Grades
3.The Highest and Lowest Test Grades
4.A list of the Grades and whether the grades is above or below average. The list should appear as follows:
Grade Status
94 Above
65 Below
85 Above
And then output all your results.
I have the first two done and keep getting compile errors on my third, when trying to bring down the number I read in from the file. Also not real sure how to begin 4th one so if you could just point me in the right direction there.
So far I have:
void function1(int ttotal, int ccount);
void function2(int nnumber);
int main()
{
int number[60];
int count = 0;
int total = 0;
int i, j;
if(!infile)
{
cout << "An error has occurred while opening the file." << endl;
frz;
exit(1);
}
for(i=0; i<60; i++)
{
number[i]=0;
}
while (!infile.eof())
{
infile >> number[i];
count++;
total = total + number[i];
cout << number[i] << endl;
}
cout << endl;
cout << count << endl;
cout << total << endl;
function1(total, count);
function2(number[i]);
infile.close();
return 0;
} //end main
//******************************************************************************
void function1(int ttotal, int ccount)
{
double average;
average = ((double)ttotal / (double)ccount);
cout << average << endl;
frz;
}
// end function1
//******************************************************************************
void function2(int nnumber)
{
int max = -100;
int min = 100;
if (number[i] > max)
{
max = number[i];
}
if (number[i] < min)
{
min = number[i];
}
cout << min << " " << max << endl;
}
// end function2
Every time I try to bring down the numbers in says in Function2 that number is not declared and i is not declared but I need to bring those down from the top to find max and min
Any suggestions for Function2 and part 4 of the directiosn to list the grades and tell whether they are above or below average.
Thanks,