Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++! Help creating a user defined function that will exlcude the minimum and max

ID: 3808973 • Letter: C

Question

C++! Help creating a user defined function that will exlcude the minimum and maxinum number. I just need the function not the whole program!

code:

//

// This function finds the minimum and maximum of a series of 5 numbers

// This function should have a void return type.

// You must use some reference parameters for this function.

//

// Write this function **********

//

void max_and_minimum (double ) {   // incomplete and probably incorrect code

double num1, num2, num3, num4, num5;

  

cout << "Enter Five numbers: ";

  

cin >> num1 >> num2 >> num3 >> num4 >> num5;

  

double minimum;

double max;

  

minimum = num1;

max = num5;

  

if ( minimum > num2) {

  

minimum = num2;

  

}

if (minimum > num3){

minimum = num3;

}

if (minimum > num4) { // end of incomplete and incorrect code

  

}

// Find the average of 5 numbers excluding the minimum and maximum

// If there is more than one number with the minimum or maximum value,

// only exclude the number one time. For example, if the numbers are:

// 4.5 6.7 2.3 7.8 2.3, the average is calculated using the numbers:

// 4.5 6.7 2.3.

//

// This function must call the above function that finds the minimum and maximum

// values in a series of 5 numbers.

//

// This function does not use reference parameters

//

// Write this function

// End of your code

////////////////////////////////

output :

O c:UserslcreillyDocumentsVisual Studio 2008 ProjectsWCSCI1370 Fall2011ContestantScore Debu This program calculates the contestant' s score based on scores from 5 judges The highest and lowest scores are dropped Score from judge 1: 7.3 Score from judge 2 8.5 Score from judge 3: 9.6 Score from judge 4: 3.5 Score from judge 5 w You entered incorrect input Enter a double between and 10: 1999929 You entered incorrect input Enter a double between 0 and 10: 23455 You entered incorrect input Enter a double between 0 and 10: 5.9 The contestant score is 7.23333 Press any key to continue

Explanation / Answer

void max_and_minimum (double ) { // incomplete and probably incorrect code
double num1, num2, num3, num4, num5;
  
cout << "Enter Five numbers: ";
  
cin >> num1 >> num2 >> num3 >> num4 >> num5;
  
double minimum;
double max;
  
minimum = num1;
max = num5;
  
if ( minimum > num2) {
minimum = num2;
}
if (minimum > num3){
minimum = num3;
}
if (minimum > num4) { // end of incomplete and incorrect code
minimum = num4;
}
if (minimum > num5) { // end of incomplete and incorrect code
minimum = num5;
}


if ( max < num1) {
max = num1;
}

if ( max < num2) {
max = num2;
}
if ( max < num3) {
max = num3;
}
if ( max < num4) {
max = num4;
}
cout<<"min is: "<<max<<endl;
cout<<"MINIMUM IS: "<<minimum<<endl;
}

It works

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote