error c2664

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

#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>

using namespace std;

void GetScores(string firstNames[], string lastNames[], double Score1[], double Score2[], double Score3[], double Score4[], double Score5[], double Score6[], double Score7[], double Score8[]);
void PrintScores(string firstNames[], string lastNames[], double totalScore[]);
double getMin(double Score1[], double Score2[], double Score3[], double Score4[], double Score5[], double Score6[], double Score7[], double Score8[]);
double getMax(double Score1[], double Score2[], double Score3[], double Score4[], double Score5[], double Score6[], double Score7[], double Score8[]);
void getSum(double totalScore[], double min, double max);


int main()
{
	string firstNames[5];
	string lastNames[5];
	double Score1[5];
	double Score2[5];
	double Score3[5];
	double Score4[5];
	double Score5[5];
	double Score6[5];
	double Score7[5];
	double Score8[5];
	double totalScore[5];

	GetScores(firstNames, lastNames, Score1, Score2, Score3, Score4, Score5, Score6, Score7, Score8);

	int i = 0;
	for (int i = 0; i < 5 ; i++)
	{
		double min = getMin(Score1[i], Score2[i], Score3[i], Score4[i], Score5[i], Score6[i], Score7[i], Score8[i]);
		double max = getMax(Score1[i], Score2[i], Score3[i], Score4[i], Score5[i], Score6[i], Score7[i], Score8[i]);
	    getSum(min, max, totalScore[i]);
	}

	PrintScores(firstNames, lastNames, totalScore);
	


	return 0;
}

void GetScores(string firstNames[], string lastNames[], double Score1[], double Score2[], double Score3[], double Score4[], double Score5[], double Score6[], double Score7[], double Score8[])
{
	ifstream infile;
	infile.open("gym.txt");
	int i = 0;
	for (i = 0; i < 5 ; i++)
		infile >> firstNames[i] >> lastNames[i] >> Score1[i] >> Score2[i] >> Score3[i] >> Score4[i] >> Score5[i] >> Score6[i] >> Score7[i] >> Score8[i] ;
		infile.close();
}


void PrintScores(string firstNames[], string lastNames[], double totalScore[])
{
}

double getMax(double Score1, double Score2, double Score3, double Score4, double Score5, double Score6, double Score7, double Score8)
{
	double max = Score1;
	if (max < Score2)
		max = Score2;
	if (max < Score3)
		max = Score3;
	if (max < Score4)
		max = Score4;
	if (max < Score5)
		max = Score5;
	if (max < Score6)
		max = Score6;
	if (max < Score7)
		max = Score7;
	if (max < Score8)
		max = Score8;
	return max;
}
double getMin(double Score1, double Score2, double Score3, double Score4, double Score5, double Score6, double Score7, double Score8)
{
	double min = Score1;
	if (min < Score2)
		min = Score2;
	if (min < Score3)
		min = Score3;
	if (min < Score4)
		min = Score4;
	if (min < Score5)
		min = Score5;
	if (min < Score6)
		min = Score6;
	if (min < Score7)
		min = Score7;
	if (min < Score8)
		min = Score8;
	return min;
}
void getSum(double min, double max, double totalScore[])
{
	int i= 0;
	for (int i = 0; i < 5 ; i++)
	totalScore[i] = totalScore[i] - min - max;
}





error C2664: 'getMin' : cannot convert parameter 1 from 'double' to 'double []'
error C2664:'getMax' : cannot convert parameter 1 from 'double' to 'double []'
error C2664: 'getSum' : cannot convert parameter 1 from 'double' to 'double []


Basically new to all of the programming with functions and such, i feel like im close to solving this but i could use some aid as to where my code is going wrong. appears to be in the function main.
when you declare the functions getMin, getMax and getSum first their parameters are double[] but when you actually write them later their parameters are double which isn't consistent with your declaration.
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
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>

using namespace std;

void GetScores(string firstNames[], string lastNames[], double Score1[], double Score2[], double Score3[], double Score4[], double Score5[], double Score6[], double Score7[], double Score8[]);
void PrintScores(string firstNames[], string lastNames[], double totalScore[]);
double getMin(double Score1[], double Score2[], double Score3[], double Score4[], double Score5[], double Score6[], double Score7[], double Score8[]);
double getMax(double Score1[], double Score2[], double Score3[], double Score4[], double Score5[], double Score6[], double Score7[], double Score8[]);
void getSum(double totalScore[], double min, double max);


int main()
{
	string firstNames[5];
	string lastNames[5];
	double Score1[5];
	double Score2[5];
	double Score3[5];
	double Score4[5];
	double Score5[5];
	double Score6[5];
	double Score7[5];
	double Score8[5];
	double totalScore[5];

	GetScores(firstNames, lastNames, Score1, Score2, Score3, Score4, Score5, Score6, Score7, Score8);

	int i = 0;
	for (int i = 0; i < 5 ; i++)
	{
		double min = getMin(Score1[i], Score2[i], Score3[i], Score4[i], Score5[i], Score6[i], Score7[i], Score8[i]);
		double max = getMax(Score1[i], Score2[i], Score3[i], Score4[i], Score5[i], Score6[i], Score7[i], Score8[i]);
	    getSum(min, max, totalScore[i]);
	}

	PrintScores(firstNames, lastNames, totalScore);
	


	return 0;
}

void GetScores(string firstNames[], string lastNames[], double Score1[], double Score2[], double Score3[], double Score4[], double Score5[], double Score6[], double Score7[], double Score8[])
{
	ifstream infile;
	infile.open("gym.txt");
	int i = 0;
	for (i = 0; i < 5 ; i++)
		infile >> firstNames[i] >> lastNames[i] >> Score1[i] >> Score2[i] >> Score3[i] >> Score4[i] >> Score5[i] >> Score6[i] >> Score7[i] >> Score8[i] ;
		infile.close();
}


void PrintScores(string firstNames[], string lastNames[], double totalScore[])
{
}

double getMax(double Score1[], double Score2[], double Score3[], double Score4[], double Score5[], double Score6[], double Score7[], double Score8[])
{
	double max = Score1;
	if (max < Score2)
		max = Score2;
	if (max < Score3)
		max = Score3;
	if (max < Score4)
		max = Score4;
	if (max < Score5)
		max = Score5;
	if (max < Score6)
		max = Score6;
	if (max < Score7)
		max = Score7;
	if (max < Score8)
		max = Score8;
	return max;
}
double getMin(double Score1[], double Score2[], double Score3[], double Score4[], double Score5[], double Score6[], double Score7[], double Score8[])
{
	double min = Score1;
	if (min < Score2)
		min = Score2;
	if (min < Score3)
		min = Score3;
	if (min < Score4)
		min = Score4;
	if (min < Score5)
		min = Score5;
	if (min < Score6)
		min = Score6;
	if (min < Score7)
		min = Score7;
	if (min < Score8)
		min = Score8;
	return min;
}
void getSum(double min, double max, double totalScore[])
{
	int i= 0;
	for (int i = 0; i < 5 ; i++)
	totalScore[i] = totalScore[i] - min - max;
}
is that what i needed to do?
Doesn't seem like you meant to pass arrays since you are using single variables.
1
2
3
double getMin(double Score1, double Score2, double Score3, double Score4, double Score5, double Score6, double Score7, double Score8);
double getMax(double Score1, double Score2, double Score3, double Score4, double Score5, double Score6, double Score7, double Score8);
void getSum(double min, double max, double totalScore[]);
Topic archived. No new replies allowed.