a

Oct 26, 2021 at 8:54am
One way is like this:

1
2
3
4
5
6
7
8
9
10
11
12
void findMin(double& lowest, double n1, double n2, double n3, double n4, double n5)
{
	lowest = n1;

	if (lowest > n2) lowest = n2;

	if (lowest > n3) lowest = n3;

	if (lowest > n4) lowest = n4;

	if (lowest > n5) lowest = n5;
}


Then when you call findMin(), the first param is set to the lowest value. This is passed by ref, the other params can be passed by value.

Same for the other required function(s).
Oct 26, 2021 at 9:36am
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
#include <iostream>
#include <string>
using namespace std;

double getScore0to10(const string& message);
double avg5Scores(double n1, double n2, double n3, double n4, double n5);

int main()
{
	cout << "This program calculates the participant's score based on\n";
	cout << "evaluator's 5 scores. The highest and lowest scores are dropped\n";

	const auto n1 {getScore0to10("Score 1: ")};
	const auto n2 {getScore0to10("Score 2: ")};
	const auto n3 {getScore0to10("Score 3: ")};
	const auto n4 {getScore0to10("Score 4: ")};
	const auto n5 {getScore0to10("Score 5: ")};

	cout << "\nThe average score is: " << avg5Scores(n1, n2, n3, n4, n5) << '\n';
}

double getScore0to10(const string& message)
{
	double num {};

	cout << message;
	cin >> num;

	while (!cin || floor(num) < 0 || ceil(num) > 10) {
		cin.clear();
		cin.ignore(5000, '\n');

		cout << "Incorrect input!\n";
		cout << "Enter a score between 0 and 10: ";
		cin >> num;
	}

	return num;
}

void findMin(double& lowest, double n1, double n2, double n3, double n4, double n5)
{
	lowest = n1;

	if (lowest > n2) lowest = n2;
	if (lowest > n3) lowest = n3;
	if (lowest > n4) lowest = n4;
	if (lowest > n5) lowest = n5;
}

void findMax(double& highest, double n1, double n2, double n3, double n4, double n5)
{
	highest = n2;

	if (highest < n1) highest = n1;
	if (highest < n3) highest = n3;
	if (highest < n4) highest = n4;
	if (highest < n5) highest = n5;
}

double avg5Scores(double n1, double n2, double n3, double n4, double n5)
{
	double lowest {}, highest {};

	findMin(lowest, n1, n2, n3, n4, n5);
	findMax(highest, n1, n2, n3, n4, n5);

	const auto sum {n1 + n2 + n3 + n4 + n5 - lowest - highest};

	return sum / 3.0;
}

Oct 26, 2021 at 12:16pm
Isn't it nice (not!) when the OP removes all of their posts after they have got the code working.....
Oct 27, 2021 at 11:30am
Who was the poster? Just so we know not to waste time with them in future.
Oct 27, 2021 at 12:17pm
I don't think the OP removed their posts. More likely that they got reported because they edited the question out, as a result the posts are removed and the account goes to limited access...I doubt you'll here from the account again.

Topic archived. No new replies allowed.