So wrote this code all in main and it worked then tried to put it into function, per assignment, and i'm getting three errors both in the last function where I call the previous functions to print.

#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
ifstream infile;

void findHighest(int score1, int score2, int score3, int score4, int score5, int score6);
void findLowest(int score1, int score2, int score3, int score4, int score5, int score6);
void findAverage(int score1, int score2, int score3, int score4, int score5, int score6);

int main()
{

infile.open("posters.txt");

string name;
int score1;
int score2;
int score3;
int score4;
int score5;
int score6;

while(infile.peek() !=EOF)
{
	infile >> name;
	infile >> score1;
	infile >> score2;
	infile >> score3;
	infile >> score4;
	infile >> score5;
	infile >> score6;
 
void findHighest(int score1, int score2, int score3, int score4, int score5, int score6);
void findLowest(int score1, int score2, int score3, int score4, int score5, int score6);
		
cout << "Results for: " << name << endl;

infile.ignore(1);
}

infile.close();

	return 0;
}

void findHighest(int score1, int score2, int score3, int score4, int score5, int score6)
{

	int max;

        if(score1>=score2 && score1>=score3 && score1>=score4 && score1>=score5 && score1>=score6) 
                max =score1; 
        else if(score2>=score3 && score2>=score4 && score2>=score5 && score2>=score6) 
                max=score2; 
        else if(score3>=score4 && score3>=score5 && score3>=score6) 
                max=score3; 
        else if(score4>=score5 && score4>=score6) 
                max=score4; 
        else if(score5>=score6) 
                max=score5; 
        else 
                max=score6;
}



void findLowest(int score1, int score2, int score3, int score4, int score5, int score6)
{
  
	int min;

        if(score1<=score2 && score1<=score3 && score1<=score4 && score1<=score5 && score1<=score6) 
                min =score1; 
        else if(score2<=score3 && score2<=score4 && score2<=score5 && score2<=score6) 
                min=score2; 
        else if(score3<=score4 && score3<=score5 && score3<=score6) 
                min=score3; 
        else if(score4<=score5 && score4<=score6) 
                min=score4; 
        else if(score5<=score6) 
                min=score5; 
        else 
                min=score6;
}

void findAverage(int score1, int score2, int score3, int score4, int score5, int score6)
{

   double sum;
   double average;
   char grade;

sum = score1 + score2 + score3 + score4 + score5 + score6;
	average = (sum - max - min)/4;

	if (average >= 8 && score1 >= 5 && score2 >= 5 && score3 >= 5 && score4 >= 5 && score5 >= 5 && score6 >= 5)
	grade = 'A';
else if (average >= 6 && score1 >= 5 && score2 >= 5 && score3 >= 5 && score4 >= 5 && score5 >= 5 && score6 >= 5)
	grade = 'B';
else 
    grade = 'C';

cout << "Highest: " << max << endl;
cout << "Lowest: " << min << endl;
cout << fixed << setprecision(2) << "Average: " << average << endl;
cout << "Grade: " << grade << endl;
cout << " " << endl;
	
}

on line 96 I get "cannot determine which instance of overloaded function "max" is intended"

on lines 105 and 106 I get "no operator "<<" matches these operands.

so I'm lost. Help Please.

Start by removing the word void from lines 35 and 36.
Re-compile and work on the first error first.

I look dumb, can't even call a function.

findHighest(score1, score2, score3, score4, score5, score6);
findLowest(score1, score2, score3, score4, score5, score6);

...better.

Now, it would be even better if your functions returned values.
findLowest should return an integer
findHighest should return an integer
findAverage should return a double

Remember to put a return ___ statement at the bottom of functions that return values.

Once you do that, you can get the values from the functions like this:

int iMax = findHighest(score1, score2, score3, score4, score5, score6);
int iMin = findLowest(score1, score2, score3, score4, score5, score6);
double dblAvg = findAverage(score1, score2, score3, score4, score5, score6);

None of the three functions should do any printing; just return values

Edited 5 Years Ago by thines01: clarity

Ok so this is what I did and now I don't get any output.

#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
ifstream infile;

int findHighest(int score1, int score2, int score3, int score4, int score5, int score6);
int findLowest(int score1, int score2, int score3, int score4, int score5, int score6);
double findAverage(int score1, int score2, int score3, int score4, int score5, int score6, int max, int min);
void getGrade(int score1, int score2, int score3, int score4, int score5, int score6, double average);
void results(int max, int min, double average, char grade);

int main()
{

infile.open("posters.txt");

string name;
int score1;
int score2;
int score3;
int score4;
int score5;
int score6;

int max = 0;
int min = 0;
char grade = 0;
double average = 0;

while(infile.peek() !=EOF)
{
	infile >> name;
	infile >> score1;
	infile >> score2;
	infile >> score3;
	infile >> score4;
	infile >> score5;
	infile >> score6;
 
findHighest(score1, score2, score3, score4, score5, score6);
findLowest(score1, score2, score3, score4, score5, score6);
	
cout << "Results for: " << name << endl;
results(max, min, average, grade);
infile.ignore(1);
}

infile.close();

	return 0;
}

int findHighest(int score1, int score2, int score3, int score4, int score5, int score6)
{

	int max;

        if(score1>=score2 && score1>=score3 && score1>=score4 && score1>=score5 && score1>=score6) 
                max =score1; 
        else if(score2>=score3 && score2>=score4 && score2>=score5 && score2>=score6) 
                max=score2; 
        else if(score3>=score4 && score3>=score5 && score3>=score6) 
                max=score3; 
        else if(score4>=score5 && score4>=score6) 
                max=score4; 
        else if(score5>=score6) 
                max=score5; 
        else 
                max=score6;
		return max;
}

int findLowest(int score1, int score2, int score3, int score4, int score5, int score6)
{
  
	int min;

        if(score1<=score2 && score1<=score3 && score1<=score4 && score1<=score5 && score1<=score6) 
                min =score1; 
        else if(score2<=score3 && score2<=score4 && score2<=score5 && score2<=score6) 
                min=score2; 
        else if(score3<=score4 && score3<=score5 && score3<=score6) 
                min=score3; 
        else if(score4<=score5 && score4<=score6) 
                min=score4; 
        else if(score5<=score6) 
                min=score5; 
        else 
                min=score6;

		return min;
}

 double findAverage(int score1, int score2, int score3, int score4, int score5, int score6, int max, int min)
{
 
   double sum;
   double average;
   
 
   sum = score1 + score2 + score3 + score4 + score5 + score6;
   average = (sum - max - min)/4;

	return average;
 }

void getGrade(int score1, int score2, int score3, int score4, int score5, int score6, double average)
{
	char grade;

	if (average >= 8 && score1 >= 5 && score2 >= 5 && score3 >= 5 && score4 >= 5 && score5 >= 5 && score6 >= 5)
	grade = 'A';
else if (average >= 6 && score1 >= 5 && score2 >= 5 && score3 >= 5 && score4 >= 5 && score5 >= 5 && score6 >= 5)
	grade = 'B';
else 
    grade = 'C';

}

void results(int max, int min, double average, char grade)
{

cout << "Highest: " << max << endl;
cout << "Lowest: " << min << endl;
cout << fixed << setprecision(2) << "Average: " << average << endl;
cout << "Grade: " << grade << endl;
cout << " " << endl;
 
}

You will actually need to put the values from the functions INTO the variables, like:

int iMax = findHighest(score1, score2, score3, score4, score5, score6);
int iMin = findLowest(score1, score2, score3, score4, score5, score6);
double dblAvg = findAverage(score1, score2, score3, score4, score5, score6);

Worked like a charm. Thanks.

#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
ifstream infile;

int findHighest(int score1, int score2, int score3, int score4, int score5, int score6);
int findLowest(int score1, int score2, int score3, int score4, int score5, int score6);
double findAverage(int score1, int score2, int score3, int score4, int score5, int score6, int max, int min);
char getGrade(int score1, int score2, int score3, int score4, int score5, int score6, double average);

int main()
{

infile.open("posters.txt");

string name;
int score1;
int score2;
int score3;
int score4;
int score5;
int score6;

int max = 0;
int min = 0;
char grade = 0;
double average = 0;

while(infile.peek() !=EOF)
{
	infile >> name;
	infile >> score1;
	infile >> score2;
	infile >> score3;
	infile >> score4;
	infile >> score5;
	infile >> score6;
 
max = findHighest(score1, score2, score3, score4, score5, score6);
min = findLowest(score1, score2, score3, score4, score5, score6);
average = findAverage(score1, score2, score3, score4, score5, score6, max, min);
grade = getGrade(score1, score2, score3, score4, score5, score6, average);
	
cout << "Results for: " << name << endl;
cout << "Highest: " << max << endl;
cout << "Lowest: " << min << endl;
cout << fixed << setprecision(2) << "Average: " << average << endl;
cout << "Grade: " << grade << endl;
cout << " " << endl;
infile.ignore(1);
}

infile.close();

	return 0;
}

int findHighest(int score1, int score2, int score3, int score4, int score5, int score6)
{

	int max;

        if(score1>=score2 && score1>=score3 && score1>=score4 && score1>=score5 && score1>=score6) 
                max =score1; 
        else if(score2>=score3 && score2>=score4 && score2>=score5 && score2>=score6) 
                max=score2; 
        else if(score3>=score4 && score3>=score5 && score3>=score6) 
                max=score3; 
        else if(score4>=score5 && score4>=score6) 
                max=score4; 
        else if(score5>=score6) 
                max=score5; 
        else 
                max=score6;
		return max;
}

int findLowest(int score1, int score2, int score3, int score4, int score5, int score6)
{
  
	int min;

        if(score1<=score2 && score1<=score3 && score1<=score4 && score1<=score5 && score1<=score6) 
                min =score1; 
        else if(score2<=score3 && score2<=score4 && score2<=score5 && score2<=score6) 
                min=score2; 
        else if(score3<=score4 && score3<=score5 && score3<=score6) 
                min=score3; 
        else if(score4<=score5 && score4<=score6) 
                min=score4; 
        else if(score5<=score6) 
                min=score5; 
        else 
                min=score6;

		return min;
}

 double findAverage(int score1, int score2, int score3, int score4, int score5, int score6, int max, int min)
{
 
   double sum;
   double average;
   
 
   sum = score1 + score2 + score3 + score4 + score5 + score6;
   average = (sum - max - min)/4;

	return average;
 }

char getGrade(int score1, int score2, int score3, int score4, int score5, int score6, double average)
{
	char grade;

	if (average >= 8 && score1 >= 5 && score2 >= 5 && score3 >= 5 && score4 >= 5 && score5 >= 5 && score6 >= 5)
	grade = 'A';
else if (average >= 6 && score1 >= 5 && score2 >= 5 && score3 >= 5 && score4 >= 5 && score5 >= 5 && score6 >= 5)
	grade = 'B';
else 
    grade = 'C';

return grade;
}
This question has already been answered. Start a new discussion instead.