for starters I'm new to coding so I am sure some of this code will look nasty and probably hard to understand. The program is supposed to have the user enter 5 classes, and 5 test scores for each class, then using functions, I need to find the lowest test score, highest test score, and the average of the scores for each class, all of which I have done in there respective functions. Then display it all using another function, there is my problem. I think it is a simple fix, but I am not sure, all I need to do is call the display function from main, and then have it display, but it just gives me syntax errors every time. Like I said, I think it will be an easy fix, but I am not sure. Any help would be appreciated!
#include "stdafx.h"
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
int minfun(int lowest, int test[5][5])
{
for (int a = 0; a < 5; a++)
{
for (int i = 0; i < 5; i++)
{
if (test[a][i] < lowest)
{
lowest = test[a][i];
}
}
}
return lowest;
}
int maxfun(int highest, int test[5][5])
{
for (int a = 0; a < 5; a++)
{
for (int i = 0; i < 5; i++)
{
if (test[a][i] > highest)
{
highest = test[a][i];
}
}
}
return highest;
}
double classavg(double avg, int sum, int test[])
{
for (int a = 0; a < 5; a++)
{
for (int i = 0; i < 5; i++)
{
sum = sum + test[a];
}
}
avg = sum / 5;
return avg;
}
void display(string classes[], int test[], int lowest, int highest, double avg)
{
minfun(lowest, test[5]);
maxfun(highest, test[5]);
classavg(avg, sum, test[5]);
for (int a = 0; a < 5; a++)
{
for (int i = 0; i < 5; i++)
{
cout << "=============================================================" << endl;
cout << "Displaying stats for " << classes[a] << endl;
cout << "Lowest test score for " << classes[a] << " is: " << lowest << endl;
cout << "Highest test score for " << classes[a] << " is: " << highest << endl;
cout << "The average for " << classes[a] << "is: " << avg << endl;
cout << "=============================================================" << endl;
}
}
//needs for loop to display stats for each class
}
int main()
{
const int max_test = 5;
int lowest = 100;
int highest = 0;
int sum = 0;
double avg = 0;
string classes[5];
int test[5][5];
cout << "Enter the name of your first class: ";
getline (cin,classes[0]);
cout << "Enter the name of your second class: ";
getline (cin, classes[1]);
cout << "Enter the name of your third class: ";
getline(cin, classes[2]);
cout << "Enter the name of your fourth class: ";
getline(cin, classes[3]);
cout << "Enter the name of your fifth class: ";
getline(cin, classes[4]);
cout << "=============================================================" << endl;
for (int a = 0; a <= max_test; a++)
{
for (int i = 1; i <= max_test; i++)
{
cout << "Enter score for test " << i << " in " << classes[a] << " : ";
cin >> test[a][i];
}
cout << "=============================================================" << endl;
}
cout << "=============================================================" << endl;
display(lowest, highest, avg);
system("pause");
return 0;
}