Write a function named testAverage that accepts four test scores as parameters and returns the average of the best three scores (that is, the average after dropping the lowest score). The data type for the scores and for the answer is double. This function must call the findLowest function you wrote in the previous problem. Do not write that function again. Do not write the main function. There should not be any cin or cout statements in this function.

Respuesta :

Answer:

The function is as follows:

double testAverage(double n1, double n2, double n3, double n4){

   double small = findLowest(n1,n2,n3,n4);

   double total = n1 + n2 + n3+ n4 - small;

   double ave = total/3;

   return ave;

}

Explanation:

This defines the function

double testAverage(double n1, double n2, double n3, double n4){

This calls the findLowesr function and save the smallest in variable small

   double small = findLowest(n1,n2,n3,n4);

This calculates the sum of the largest 3

   double total = n1 + n2 + n3+ n4 - small;

This calculates the average of the largest 3

   double ave = total/3;

This returns the calculated average

   return ave;

}

Note that: I assume that function findLowest exists (according to the question).