Unable to see problems with my code

I have tried to debug the program through Visual studio 2012, but keep getting an error about missing an .exe file. So I can't really debug the code to see what's wrong with it.

This is my code, it's for a program (basically a modification of the Star Search program) that reads data from an input file and requires the use of functions and passing reference parameters (something that I've never fully understood, but we've gotta use it for this) and arrays aren't allowed to be used in this program :/. It also produces an output file with the name and final score

Example input:
Lucy 9 9 8 10 9.8
Amir 8 7 9.8 10 10

Example output:
Micheal 9.7
Cindy 8.8

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
#include <fstream>
using namespace std;

//function prototypes
string contestantName(ifstream&);
double getJudgeData(ifstream&);
double findLowest(double &lowestScore);
double findHighest(double &highestScore);
double calcScore(double&);

//variables
string contName;
double score1, score2, score3, score4, score5, lowestScore, highestScore, totalScore;

int main()
{
	int contNumber; //number of contestants
	ifstream inputFile;
	inputFile.open("starsearch.dat");
	inputFile >> contNumber; //calls functions how many times contNumber is

	for (int count = 0; count < contNumber; count++)
	{
		string contestantName(contName);
		getJudgeData(inputFile);
		CalcScore(totalScore);
		ofstream outputFile;
		outputFile.open ("results.dat");
		outputFile << contName << totalScore;
	}
system("pause");
return 0;
}

//returns contestant's name to put put in the output file results.dat
string contestantName (string contName)
{
	ifstream inputFile;
	inputFile.open("starsearch.dat");
	inputFile >> contName;
	return contName;
}

//reads all 5 scores from input file 'starsearch.dat'
double getJudgeData(ifstream &ifstreamRef)
{
	ifstream inputFile;
	inputFile.open("starsearch.dat");
    inputFile >> score1 >> score2 >> score3 >> score4 >> score5;
	return score1 + score2 + score3 + score4 + score5;
}

//determines lowest score to omit from the 5 scores
double findLowest(double &lowestScore)
{
	if ((score1 <= score2) && (score1 <= score3) && (score1 <= score4) && (score1 <= score5))
	{
		lowestScore = score1; 
	}
			
	else if ((score2 <= score1) && (score2 <= score3) && (score2 <= score4) && (score2 <= score5))
	{
		lowestScore = score2; 
	}

	else if ((score3 <= score1) && (score3 <= score2) && (score3 <= score4) && (score3 <= score5))
	{
		lowestScore = score3; 
	}

	else if ((score4 <= score1) && (score4 <= score2) && (score4 <= score3) && (score4 <= score5))
	{	
		
		lowestScore = score4;
	}

	else if ((score5 <= score1) && (score5 <= score2) && (score5 <= score3) && (score5 <= score4))
	{
		lowestScore = score5; 
	}
	return lowestScore;
}

//determines highest score to omit from the 5 scores
double findHighest(double &highestScore)
{
	if ((score1 >= score2) && (score1 >= score3) && (score1 >= score4) && (score1 >= score5))
	{
		highestScore = score1; 
	}
			
	else if ((score2 >= score1) && (score2 >= score3) && (score2 >= score4) && (score2 >= score5))
	{
		highestScore = score2; 
	}

	else if ((score3 >= score1) && (score3 >= score2) && (score3 >= score4) && (score3 >= score5))
	{
		highestScore = score3; 
	}

	else if ((score4 >= score1) && (score4 >= score2) && (score4 >= score3) && (score4 >= score5))
	{
		highestScore = score4;
	}

	else if ((score5 >= score1) && (score5 >= score2) && (score5 >= score3) && (score5 >= score4))
	{
		highestScore = score5; 
	}
	return highestScore;
}

//returns the total score after averaging the 3 scores left after removing the 1 highest and 1 lowest score
double calcScore (double &totalScore)
{
	double findLowest(double lowestScore);
	double findHighest(double highestScore);
	totalScore = (((score1+score2+score3+score4+score5)-(lowestScore+highestScore))/3.0);
	return totalScore;
}


I know there are errors but at this point I'm having trouble finding them.
Last edited on
> but keep getting an error about missing an .exe file
¿why do you paraphrase an error that you don't understand?

Your code does not compile
foo.cpp: In function ‘int main()’:
foo.cpp:32:24: error: ‘CalcScore’ was not declared in this scope
foo.cpp:37:17: error: ‘system’ was not declared in this scope
foo.cpp: At global scope:
foo.cpp:53:1: warning: unused parameter ‘ifstreamRef’ [-Wunused-parameter]



> Also I know the indents probably aren't right, but they're only like this on here, not in my actual program.
Don't mix tabs and spaces in the indentation.
However, that would not explain what happened at line 91
Last edited on
> but keep getting an error about missing an .exe file
¿why do you paraphrase an error that you don't understand?

Your code does not compile
foo.cpp: In function ‘int main()’:
foo.cpp:32:24: error: ‘CalcScore’ was not declared in this scope
foo.cpp:37:17: error: ‘system’ was not declared in this scope
foo.cpp: At global scope:
foo.cpp:53:1: warning: unused parameter ‘ifstreamRef’ [-Wunused-parameter]



> Also I know the indents probably aren't right, but they're only like this on here, not in my actual program.
Don't mix tabs and spaces in the indentation.
However, that would not explain what happened at line 91


Ok, let's just forget the .exe thing for now. But about my code not compiling (and thank you for showing this, since it was something it wasn't letting me do)

-system isnt' supposed to be declared, it's supposed to be like that. It keeps the command prompt window from closing too quickly. So I have no idea what it means
-and at ifstreamRef, I don't know how to fix that. Reference parameters already make too little sense to me as it is.
Last edited on
> system isnt' supposed to be declared,
everything that you want to use must be declared prior to its first use.
You can declare `system()' by #include <cstdlib>

> It keeps the command prompt window from closing too quickly.
http://www.cplusplus.com/forum/articles/11153/
http://www.cplusplus.com/articles/iw6AC542/


> and at ifstreamRef, I don't know how to fix that.
It is not an error, but a warning.
If you are not going to use the parameter that you pass to the function, then the function should not ask for such a parameter
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
double getJudgeData()
{
	ifstream inputFile;
	inputFile.open("starsearch.dat");
	inputFile >> score1 >> score2 >> score3 >> score4 >> score5;
	return score1 + score2 + score3 + score4 + score5;
}

//alternative, use the parameter
double getJudgeData(ifstream &inputFile)
{
	//client must open the file prior to call this function
	inputFile >> score1 >> score2 >> score3 >> score4 >> score5;
	return score1 + score2 + score3 + score4 + score5;
}



> But about my code not compiling (and thank you for showing this, since it was something it wasn't letting me do)
¿what? ¿it doesn't show you error messages?

By the way, it remains to correct the case in `CalcScore()'
everything that you want to use must be declared prior to its first use.
You can declare `system()' by #include <cstdlib>

That's odd since I've never had to do that with other programs that involved system("pause") that worked and compiled just fine. Plus our instructor never taught us how to use anything else, same with using namespace std;.

> and at ifstreamRef, I don't know how to fix that.
It is not an error, but a warning.
If you are not going to use the parameter that you pass to the function, then the function should not ask for such a parameter

The specifications for this program is that getJudgeData() is supposed to use a reference parameter for the score (the scores from starsearch.dat)

> But about my code not compiling (and thank you for showing this, since it was something it wasn't letting me do)
¿what? ¿it doesn't show you error messages?

By the way, it remains to correct the case in `CalcScore()'

And yes. Let's say for example, I would have a program that had errors in it but would still compile (i.e. bring up the command window), it would for a split second show the errors in the console but then those disappear when the command window pops up.

I corrected 'CalcScore()' to calcScore() like it's supposed to, but it didn't really fix anything by doing so.


I also want to add that I managed to copy and paste the error messages it was giving me.

1>Source.obj : error LNK2019: unresolved external symbol "double __cdecl getJudgeData(class std::basic_ifstream<char,struct std::char_traits<char> > &)" (?getJudgeData@@YANAAV?$basic_ifstream@DU?$char_traits@D@std@@@std@@@Z) referenced in function _main

1>C:\Users\Olivia\My Classes\C++[ONLINE]\Projects (Name - Due Date)\StarSearchh\Debug\StarSearchh.exe : fatal error LNK1120: 1 unresolved externals

What is this greek.
Last edited on
> That's odd since I've never had to do that with other programs that involved system("pause")
> that worked and compiled just fine
Another header may have include it. However that's only a side effect of your version of compiler, and may produce errors if you change version or compiler.
So if you want to use a function, you ought to include the correspondent header.


About your errors
<nolyc> Undefined reference is a linker error.
It's not a compile error. #includes don't help.
You did not define the thing in the error message, you forgot to link the file that defines it, you forgot to link to the library that defines it, or, if it's a static library, you have the wrong order on the linker command line.
Check which one. (Note that some linkers call it an unresolved external)


If you have modified your code, then upload the modified version
There isn't much in here modified, since I'm still very confused on how to fix these errors.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
#include <fstream>
using namespace std;

//function prototypes
string contestantName();
double getJudgeData();
double findLowest(double &lowestScore);
double findHighest(double &highestScore);
double calcScore(double&);

//variables
string contName;
double score1, score2, score3, score4, score5, lowestScore, highestScore, totalScore;

int main()
{
	int contNumber; //number of contestants
	ifstream inputFile;
	inputFile.open("starsearch.dat");
	inputFile >> contNumber; //calls functions how many times contNumber is

	for (int count = 0; count < contNumber; count++)
	{
		string contestantName(contName);
		getJudgeData();
		calcScore(totalScore);
		ofstream outputFile;
		outputFile.open ("results.dat");
		outputFile << contName << totalScore;
	}
system("pause");
return 0;
}

//returns contestant's name to put put in the output file results.dat
string contestantName (string contName)
{
	ifstream inputFile;
	inputFile.open("starsearch.dat");
	inputFile >> contName;
	return contName;
}

//reads all 5 scores from input file 'starsearch.dat'
double getJudgeData(ifstream contScores)
{
	ifstream inputFile;
	inputFile.open("starsearch.dat");
    inputFile >> score1 >> score2 >> score3 >> score4 >> score5;
	return score1 + score2 + score3 + score4 + score5;
}

//determines lowest score to omit from the 5 scores
double findLowest(double &lowestScore)
{
	if ((score1 <= score2) && (score1 <= score3) && (score1 <= score4) && (score1 <= score5))
	{
		lowestScore = score1; 
	}
			
	else if ((score2 <= score1) && (score2 <= score3) && (score2 <= score4) && (score2 <= score5))
	{
		lowestScore = score2; 
	}

	else if ((score3 <= score1) && (score3 <= score2) && (score3 <= score4) && (score3 <= score5))
	{
		lowestScore = score3; 
	}

	else if ((score4 <= score1) && (score4 <= score2) && (score4 <= score3) && (score4 <= score5))
	{	
		
		lowestScore = score4;
	}

	else if ((score5 <= score1) && (score5 <= score2) && (score5 <= score3) && (score5 <= score4))
	{
		lowestScore = score5; 
	}
	return lowestScore;
}

//determines highest score to omit from the 5 scores
double findHighest(double &highestScore)
{
	if ((score1 >= score2) && (score1 >= score3) && (score1 >= score4) && (score1 >= score5))
	{
		highestScore = score1; 
	}
			
	else if ((score2 >= score1) && (score2 >= score3) && (score2 >= score4) && (score2 >= score5))
	{
		highestScore = score2; 
	}

	else if ((score3 >= score1) && (score3 >= score2) && (score3 >= score4) && (score3 >= score5))
	{
		highestScore = score3; 
	}

	else if ((score4 >= score1) && (score4 >= score2) && (score4 >= score3) && (score4 >= score5))
	{
		highestScore = score4;
	}

	else if ((score5 >= score1) && (score5 >= score2) && (score5 >= score3) && (score5 >= score4))
	{
		highestScore = score5; 
	}
	return highestScore;
}

//returns the total score after averaging the 3 scores left after removing the 1 highest and 1 lowest score
double calcScore (double &totalScore)
{
	double findLowest(double lowestScore);
	double findHighest(double highestScore);
	totalScore = (((score1+score2+score3+score4+score5)-(lowestScore+highestScore))/3.0);
	return totalScore;
}


All I really did was remove the parameter things where the function prototypes are for contestantName and getJudgeData since I'm clueless at this point about these.

Here are the specifications that are just confusing the heck out of me, which is probably why I'm having so much trouble understanding this:

1. Your program will have a function called string contestantName() that takes the file object as a reference parameter and reads the file for the name of the contestant on the current line and returns the name. This function should be called from main, once for each line of the file.

2. The void getJudgeData() will read from the file and not from the user. This function will still use a reference parameter for the score, and it will read the next score from the file. This function will be called five times per contestant and is called from main once for each score.

3. The void CalcScore() is used to calculate the score using the same formulation. However, this function will write the contestants name and score to an output file. The function will have 7 parameters instead of 5: output file (pass by reference), contestants' name, and the 5 judges scores.
You declared double getJudgeData();, you called getJudgeData(); but you defined double getJudgeData(ifstream contScores)
¿see the problem?

According to the specifications
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
void getJudgeData(std::ifstream &input, double &score){
	input>>score;
}

std::string contestantName(std::ifstream &input);
void CalcScore(std::ofstream &output, std::string name, std::array<double,5> score); //I'm too lazy to write 5 parameters

int main(){
	int contNumber; //number of contestants
	ifstream inputFile("starsearch.dat"); //you open the files at the time of construction, just one time
	ofstream outputFile("results.dat");

	inputFile >> contNumber;
	for (int count = 0; count < contNumber; count++)
	{
		std::string name = contestantName(input);
		double score1, score2, score3, score4, score5; //limit the scope of your variables
		//a loop with an array would be more maintainable
		getJudgeData(input, score1);
		//...
		getJudgeData(input, score5);
		
		CalcScore(output, name, score{1..5}); //again, I'm lazy
	}
}


Also double findLowest(double lowestScore); is not a function call
Last edited on
The thing is we're not allowed to use arrays :/ , so I'm unsure of how to go about this. I'm guessing I can just write the 5 parameters (score1, score2, etc.) in place of that?

EDIT: Here's my edited code with what you suggested. I made the variables global because it's saying it's undefined in each function.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
#include <fstream>
using namespace std;

//function prototypes
string contestantName();
void getJudgeData();
double findLowest(double &lowestScore);
double findHighest(double &highestScore);
double calcScore(double&);

//variables
string contName;

int main()
{
	int contNumber; //number of contestants
	ifstream inputFile("starsearch.dat");
	ofstream outputFile("results.dat");
	
	inputFile >> contNumber; //calls functions how many times contNumber is
	for (int count = 0; count < contNumber; count++)
	{
		string contestantName(contName);
		double score1, score2, score3, score4, score5;
		double totalScore;
		//I changed input to inputFile, since I think that's
		//what you were going at, and it said input was undefined
		getJudgeData(inputFile, score1);
		getJudgeData(inputFile, score2);
		getJudgeData(inputFile, score3);
		getJudgeData(inputFile, score4);
		getJudgeData(inputFile, score5);
		//calcScore is giving me an issue of 'no instance of overloaded
		//function
		calcScore(score1, score2, score3, score4, score5);
		ofstream outputFile;
		outputFile.open ("results.dat");
		outputFile << contName << totalScore;
	}
system("pause");
return 0;
}

//returns contestant's name to put put in the output file results.dat
string contestantName (string contName)
{
	ifstream inputFile;
	inputFile.open("starsearch.dat");
	inputFile >> contName;
	return contName;
}

//reads all 5 scores from input file 'starsearch.dat'
void getJudgeData(ifstream &input, double &score)
//it's saying inputFile is undefined, do I need to define it
//in each function?
{
    inputFile >> score1 >> score2 >> score3 >> score4 >> score5;
	return score1 + score2 + score3 + score4 + score5;
}

//determines lowest score to omit from the 5 scores
double findLowest(double &lowestScore)
{
	if ((score1 <= score2) && (score1 <= score3) && (score1 <= score4) && (score1 <= score5))
	{
		lowestScore = score1; 
	}
			
	else if ((score2 <= score1) && (score2 <= score3) && (score2 <= score4) && (score2 <= score5))
	{
		lowestScore = score2; 
	}

	else if ((score3 <= score1) && (score3 <= score2) && (score3 <= score4) && (score3 <= score5))
	{
		lowestScore = score3; 
	}

	else if ((score4 <= score1) && (score4 <= score2) && (score4 <= score3) && (score4 <= score5))
	{	
		
		lowestScore = score4;
	}

	else if ((score5 <= score1) && (score5 <= score2) && (score5 <= score3) && (score5 <= score4))
	{
		lowestScore = score5; 
	}
	return lowestScore;
}

//determines highest score to omit from the 5 scores
double findHighest(double &highestScore)
{
	if ((score1 >= score2) && (score1 >= score3) && (score1 >= score4) && (score1 >= score5))
	{
		highestScore = score1; 
	}
			
	else if ((score2 >= score1) && (score2 >= score3) && (score2 >= score4) && (score2 >= score5))
	{
		highestScore = score2; 
	}

	else if ((score3 >= score1) && (score3 >= score2) && (score3 >= score4) && (score3 >= score5))
	{
		highestScore = score3; 
	}

	else if ((score4 >= score1) && (score4 >= score2) && (score4 >= score3) && (score4 >= score5))
	{
		highestScore = score4;
	}

	else if ((score5 >= score1) && (score5 >= score2) && (score5 >= score3) && (score5 >= score4))
	{
		highestScore = score5; 
	}
	return highestScore;
}

//returns the total score after averaging the 3 scores left after removing the 1 highest and 1 lowest score
void calcScore (ofstream &output, string name, double score1, double score2, double score3, double score4, double score5)
{
	double findLowest(double lowestScore);
	double findHighest(double highestScore);
	totalScore = (((score1+score2+score3+score4+score5)-(lowestScore+highestScore))/3.0);
	return totalScore;
}
Last edited on
Yes, that's too much work for me
I don't mind doing all that extra typing as long as this program works :/

But will redefining all the variables in each of the functions do the trick? Or just make them global again?

This is a pretty bad problem I will admit, since we're so limited on what we're allowed to use.

I'll post my edited code again, even though it's horrendous. I'm hopelessly lost at this point.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
#include <fstream>
using namespace std;

//function prototypes
string contestantName();
double getJudgeData();
double findLowest(double &lowestScore);
double findHighest(double &highestScore);
double calcScore(double&);

//variables
string contName;

int main()
{
	int contNumber; //number of contestants
	ifstream inputFile("starsearch.dat");
	ofstream outputFile("results.dat");
	
	inputFile >> contNumber; //calls functions how many times contNumber is
	for (int count = 0; count < contNumber; count++)
	{
		string contestantName(contName);
		double score1, score2, score3, score4, score5;
		double totalScore;
		//I changed input to inputFile, since I think that's
		//what you were going at, and it said input was undefined
		getJudgeData(inputFile, score1);
		getJudgeData(inputFile, score2);
		getJudgeData(inputFile, score3);
		getJudgeData(inputFile, score4);
		getJudgeData(inputFile, score5);
		//calcScore is giving me an issue of 'no instance of overloaded
		//function
		calcScore(score1, score2, score3, score4, score5);
		ofstream outputFile;
		outputFile.open ("results.dat");
		outputFile << contName << totalScore;
	}
system("pause");
return 0;
}

//returns contestant's name to put put in the output file results.dat
string contestantName (string contName)
{
	ifstream inputFile;
	inputFile.open("starsearch.dat");
	inputFile >> contName;
	return contName;
}

//reads all 5 scores from input file 'starsearch.dat'
double getJudgeData(ifstream &input, double &score)
//it's saying inputFile is undefined, do I need to define it
//in each function?
{
	ifstream inputFile;
	double score1, score2, score3, score4, score5;
    inputFile >> score1 >> score2 >> score3 >> score4 >> score5;
	return score1 + score2 + score3 + score4 + score5;
}

//determines lowest score to omit from the 5 scores
double findLowest(double &lowestScore)
{
	double score1, score2, score3, score4, score5;
	if ((score1 <= score2) && (score1 <= score3) && (score1 <= score4) && (score1 <= score5))
	{
		lowestScore = score1; 
	}
			
	else if ((score2 <= score1) && (score2 <= score3) && (score2 <= score4) && (score2 <= score5))
	{
		lowestScore = score2; 
	}

	else if ((score3 <= score1) && (score3 <= score2) && (score3 <= score4) && (score3 <= score5))
	{
		lowestScore = score3; 
	}

	else if ((score4 <= score1) && (score4 <= score2) && (score4 <= score3) && (score4 <= score5))
	{	
		
		lowestScore = score4;
	}

	else if ((score5 <= score1) && (score5 <= score2) && (score5 <= score3) && (score5 <= score4))
	{
		lowestScore = score5; 
	}
	return lowestScore;
}

//determines highest score to omit from the 5 scores
double findHighest(double &highestScore)
{
	double score1, score2, score3, score4, score5;
	if ((score1 >= score2) && (score1 >= score3) && (score1 >= score4) && (score1 >= score5))
	{
		highestScore = score1; 
	}
			
	else if ((score2 >= score1) && (score2 >= score3) && (score2 >= score4) && (score2 >= score5))
	{
		highestScore = score2; 
	}

	else if ((score3 >= score1) && (score3 >= score2) && (score3 >= score4) && (score3 >= score5))
	{
		highestScore = score3; 
	}

	else if ((score4 >= score1) && (score4 >= score2) && (score4 >= score3) && (score4 >= score5))
	{
		highestScore = score4;
	}

	else if ((score5 >= score1) && (score5 >= score2) && (score5 >= score3) && (score5 >= score4))
	{
		highestScore = score5; 
	}
	return highestScore;
}

//returns the total score after averaging the 3 scores left after removing the 1 highest and 1 lowest score
double calcScore (double score1, double score2, double score3, double score4, double score5)
{
	double totalScore;
	double lowestScore;
	double highestScore;
	double findLowest(double lowestScore);
	double findHighest(double highestScore);
	totalScore = (((score1+score2+score3+score4+score5)-(lowestScore+highestScore))/3.0);
	return totalScore;
}


I redefined the variables in each function, but I'm not sure how to even fix this at this point.
Last edited on
I've already show you how to code `getJudgeData()'
The prototypes in declaration and definition must match

Taking that as an example, I thought that you wouldn't have a problem in coding `contestantName()' (for which I've provided the prototype)
Don't open the file inside the function, just use it. The file is opened in `main()'
Also, string contestantName(contName); is not calling a function. It is creating an string variable, named `contestantName' that has the same content as the `name' string.
The call should be std::string name = contestantName(input); or std::string name( contestantName(input) ); if you prefer.



> But will redefining all the variables in each of the functions do the trick?
They are different variables, in different scopes. The name means nothing.


Again, double findLowest(double lowestScore); is not a function call
A function call would be like double highestScore = findHighest(score1,score2,score3,score4,score5); (changing the prototype according)
Topic archived. No new replies allowed.