Trying to write a program for my C++ class.

Basically; call a function getJudgeData five times within the main function to get five different scores. Send the scores from getJudgeData function to calcScore function. From there use two more functions, findHighest and findLowest to find the highest and lowest score, then send them back to calcScore. Subtract those two scores from the rest and average what's left.

ANYWAY. I pretty much have this program down, I just can't seem to find whatever stupid mistake I made that gives me the following errors:


Error 1 error C2660: 'getJudgeData' : function does not take 1 arguments c:\users\jessikwa\documents\visual studio 2010\projects\star search\star search\main.cpp 9 1 Star Search
Error 2 error C2660: 'getJudgeData' : function does not take 1 arguments c:\users\jessikwa\documents\visual studio 2010\projects\star search\star search\main.cpp 10 1 Star Search
Error 3 error C2660: 'getJudgeData' : function does not take 1 arguments c:\users\jessikwa\documents\visual studio 2010\projects\star search\star search\main.cpp 11 1 Star Search
Error 4 error C2660: 'getJudgeData' : function does not take 1 arguments c:\users\jessikwa\documents\visual studio 2010\projects\star search\star search\main.cpp 12 1 Star Search
Error 5 error C2660: 'getJudgeData' : function does not take 1 arguments c:\users\jessikwa\documents\visual studio 2010\projects\star search\star search\main.cpp 13 1 Star Search
Error 6 error C2660: 'calcScore' : function does not take 5 arguments c:\users\jessikwa\documents\visual studio 2010\projects\star search\star search\main.cpp 41 1 Star Search
Error 7 error C2660: 'findHighest' : function does not take 5 arguments c:\users\jessikwa\documents\visual studio 2010\projects\star search\star search\main.cpp 48 1 Star Search
Error 8 error C2660: 'findLowest' : function does not take 5 arguments c:\users\jessikwa\documents\visual studio 2010\projects\star search\star search\main.cpp 49 1 Star Search

Here is my code:

#include <iostream>
using namespace std;
void getJudgeData();
void calcScore();
double findHighest();
double findLowest();
	int main()
	{
		getJudgeData(1);
		getJudgeData(2);
		getJudgeData(3);
		getJudgeData(4);
		getJudgeData(5);

		system("pause");
		return 0;
	}

	void getJudgeData(int count)
{
	double score1, score2, score3, score4, score5;

	switch(count)
	{
		case 1: cout << "Please enter the score for judge " << count;
	            cin >> score1;
				break;
		case 2: cout << "Please enter the score for judge " << count;
	            cin >> score2;
		case 3: cout << "Please enter the score for judge " << count;
	            cin >> score3;
				break;
	    case 4: cout << "Please enter the score for judge " << count;
	            cin >> score4;
				break;
		case 5: cout << "Please enter the score for judge " << count;
	            cin >> score5;
				break;
	}

	calcScore(score1, score2, score3, score4, score5);
}

void calcScore(double one, double two, double three, double four, double five)
{
	double hs, ls, avg;

		hs = findHighest(one, two, three, four, five);
		ls = findLowest(one, two, three, four, five);

		avg = ((one + two + three + four + five) - (hs+ls))/3;

		cout << "The contestant's final score was " << avg;
}

double findHighest(double h1, double h2, double h3, double h4, double h5)
{
	double hs = 10;

		if (h1 > hs)
		{
			h1 = hs;
		}
		else if (h2 > hs)
		{
			h2 = hs;
		}
		else if (h3 > hs)
		{
			h3 = hs;
		}
		else if (h4 > hs)
		{
			h4 = hs;
		}
		else if (h5 > hs)
		{
			h5 = hs;
		}

		return hs;
}

double findLowest (double l1, double l2, double l3, double l4, double l5)
{
	double ls = 1;

		if (l1 < ls)
		{
			l1 = ls;
		}
		else if (l2 < ls)
		{
			l2 = ls;
		}
		else if (l3 < ls)
		{
			l3 = ls;
		}
		else if (l4 < ls)
		{
			l4 = ls;
		}
		else if (l5 < ls)
		{
			l5 = ls;
		}

		return ls;
}

Any help is MUCH appreciated.

Oh, minding also that this code is missing a line in the main function that calls the calcScore function..

The problem is function declarations, you have declared both functions to take 0 arguments -

void getJudgeData();
void calcScore();

Correct them and it should work. And using system("pause") is not good.

Edited 6 Years Ago by vidit_X: n/a

I don't think I understand. I took this as:
void calcScore(5);

Which causes more errors. Could you explain this more for me?

I'm sorry if this is common sense, I'm very tired, and I've been flipping through my book looking for answers for awhile now, to no avail.

I'm sorry, nevermind. I understand what you meant for me to do now. I'm going to fix up my code and check back in a minute. Thank you.

Hey no need to be sorry. What I meant is look at your function signature in declaration. Line 4.

void calcScore()

and the function signature in definition. Line 44.

void calcScore(double one, double two, double three, double four, double five)

Similarly, for the function getJudgeData(). The function declaration and definition should match.

Edited 6 Years Ago by vidit_X: n/a

Yes, this was the problem solver to the "function does not take (x) arguments" issue. I'm almooooost there! (thank you again for that)

#include <iostream>
using namespace std;
void getJudgeData(int);
void calcScore(double, double, double, double, double);
double findHighest(double, double, double, double, double);
double findLowest(double, double, double, double, double);
	int main()
	{
		getJudgeData(1);
		getJudgeData(2);
		getJudgeData(3);
		getJudgeData(4);
		getJudgeData(5);

		calcScore();
 
		system("pause");
		return 0;
	}
 
	void getJudgeData(int count)
{
	double score1, score2, score3, score4, score5;
 
	switch(count)
	{
		case 1: cout << "Please enter the score for judge " << count << ". ";
	            cin >> score1;
				break;
		case 2: cout << "Please enter the score for judge " << count << ". ";
	            cin >> score2;
				break;
		case 3: cout << "Please enter the score for judge " << count << ". ";
	            cin >> score3;
				break;
	    case 4: cout << "Please enter the score for judge " << count << ". ";
	            cin >> score4;
				break;
		case 5: cout << "Please enter the score for judge " << count << ". ";
	            cin >> score5;
				break;
				calcScore(score1, score2, score3, score4, score5);
	}
}
 
void calcScore(double one, double two, double three, double four, double five)
{
	double hs, ls, avg;
 
		hs = findHighest(one, two, three, four, five);
		ls = findLowest(one, two, three, four, five);
 
		avg = ((one + two + three + four + five) - (hs+ls))/3;
 
		cout << "The contestant's final score was " << avg <<endl;
		return;
}
 
double findHighest(double h1, double h2, double h3, double h4, double h5)
{
	double hs = 10;
 
		if (h1 > hs)
		{
			h1 = hs;
		}
		else if (h2 > hs)
		{
			h2 = hs;
		}
		else if (h3 > hs)
		{
			h3 = hs;
		}
		else if (h4 > hs)
		{
			h4 = hs;
		}
		else if (h5 > hs)
		{
			h5 = hs;
		}
 
		return hs;
}
 
double findLowest (double l1, double l2, double l3, double l4, double l5)
{
	double ls = 1;
 
		if (l1 < ls)
		{
			l1 = ls;
		}
		else if (l2 < ls)
		{
			l2 = ls;
		}
		else if (l3 < ls)
		{
			l3 = ls;
		}
		else if (l4 < ls)
		{
			l4 = ls;
		}
		else if (l5 < ls)
		{
			l5 = ls;
		}
 
		return ls;
}

Line 15 when I try to call the calcScore function is my last issue.. how would I go about doing this, without changing the values I've passed to that function?

One of the fix is to declare score1, score2 and so on as global variables and then pass them to calcScore() but using global variables is not advised.

Edited 6 Years Ago by vidit_X: n/a

Yes, I know. I'm trying to call it without changing the values I passed to it from getJudgeData, is this even possible?

Everytime you call getJudgeData(), only one of the variables score1 or score2 or ...
gets a value, not all and between different calls of the same fucntion, the values are not retained.

Also, the call to calcScore() inside getJudgeData() would never be reached. Hope you getting what I mean.

I ended up rearranging a few things. Rather than passing the scores from function to function, I passed them back to main, then to the function I wanted.

Thank you so much for your help, it's been a long night, I'm glad this has been solved lol.

This question has already been answered. Start a new discussion instead.