Need to create a program to evaluate some scores in functions

The professor gave us a problem to solve by ourselves that used functions. She gave is the entire class to do it after she gave discussed a few things (the class is 4 hours long) and we had 3 to work with the program. I tried to make it work, but nothing. It falls into a loop and it doesn't work at all. I don't know where the problem is and the prof didn't want to help me. The problem needs to be done in more than one function.

Here is the problem:
Problem 1:
A particular talent competition has five judges, each of whom awards a score between 0 and 10 to each performer. Fractional scores, such as 7.6, are allowed. A performer’s final score is determined by dropping the highest and lowest score received, then averaging the three remaining scores. Design and write a program using functions (several functions according your design/solution) that uses this method to calculate a contestant’s score.
Input Validation: Do not accept judge scores lower than 0 or higher than 10.


Here is the code:
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
#include <iostream>
#include <iomanip>

using namespace std;

double validation ();
double findLowest(int, double &);
double findHighest(int, double &);
double Average(int, double);

int i = 0, n = 5;

int main(){
	
	double min, max, total = 0, avg;

	min = findLowest(n, total);
	max = findHighest(n, total);
        avg = Average(n, total);

	cout << fixed << setprecision(1);
	cout << "Lowest Score: "<<min<<endl;
	cout << "Highest Score: "<<max<<endl;
	cout << "Final Score: "<<avg<<endl;
	
system("pause");
return 0;
}

double validation(){
	double x;

	for(int score = 1; score = 5; score++){
			
		cout << "Score "<< i+1<<": ";
		cin >> x;
		i++;

	while(x>=0 || x<=10)
		cout<<"Invalid Score. Try again.";
		return x;	
	}
}

double findLowest(int n, double &total)
{
	double min, g;
	for (int j = 1; j <=5; j++)
	{
		g = validation();
		total += g;

		if (j == 1)
			min = g;
		else if (g < min)
			min = g;
	}

	total -= min;
	return min;
}

double findHighest(int n, double &total)
{
	double max, g;
	for (int j = 1; j <=5; j++)
	{
		g = validation();
		total += g;

		if (j == 1)
			max = g;
		else if (g > max)
			max = g;
	}

	total += max;
	return max;
}

double Average(int n, double total)
{
	double avg;
	avg = total / 3;
	return avg;
}
Last edited on
Topic archived. No new replies allowed.