a

One way is like this:

 ``123456789101112`` ``````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).
 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071`` ``````#include #include 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; }``````

Isn't it nice (not!) when the OP removes all of their posts after they have got the code working.....
Who was the poster? Just so we know not to waste time with them in future.
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.