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

Determine the average of a set of numbers after eliminating the smallest and lar

ID: 3583542 • Letter: D

Question

Determine the average of a set of numbers after eliminating the smallest and largest values from the set. The next Winter Olympics is two years away, but the International Olympic Committee (IOC) wants you to develop a computer system that will determine the trimmed or truncated mean of the scores from a judging panel used for Olympic skating events. The specific truncated mean that the IOC requires is the average of the remaining scores, after the lowest and highest scores have been discarded. Your solution can assume there are seven judges, and the final result will be the average of the five middle scores. The system architect for this project has produced a high-level design by functionally decomposing the overall task into the following mainline and major subtasks: You may submit a solution in pseudocode, flowcharts or Alice. Complete solutions will have six separate modules, per the functional decomposition above. For pseudocode and flowcharts, assume that an array can be an explicit return value. That is, use: return arrayName to return an array to the calling code, where arrayName is the identifier of the array variable. Assume that an array can be passed into a module by using its name in the parameter list. For example, the following illustrates what the instruction that calls the calculation module might look like: finalScore = calculateTruncatedMean(scores, smallest, largest) ... where scores is the array holding the scores, and smallest and largest are the min and max scores, respectively. Note that for both return values and arguments, the array name is used without square brackets; but include the brackets and the size when an array is declared as a formal parameter.

Explanation / Answer

First Declare the auxiliary methods

Define Method getScores():
   Scores [someSize];
   Loop x in [0,someSize]:
       Scores[x] = userInput();
   Return scores;

Method findMin(scores[]):
   Initialize min = Some Compiler dependent largest value(eg. Integer.MAX_VALUE in java);
   Iterate score in scores[]:
       If score < min
           Then Min = score;
   Return min;

Method findMax(scores[]):
   Initialize max = Some Compiler dependent Smallest value(eg. Integer.MIN_VALUE in java);
   Loop score in scores[]:
       If max < score
           Then Max = score;
Return max;

Define Method calculateTruncatedMean(scores[],smallest,largest):
       Sum = 0;
Count =0; // count is the number of scores excluding largest and smallest since there can be duplicate largest and smallest hence average cannot be (score/scores[].length – 2)
       Loop score in scores[]:
            If(score!=smallest And score!=largest)
               Sum = 0;
               Count++;
       Return sum/count;

Define methos Report(scores[],finalResult,smallest,largest):

       Loop score in scores[]:
           If(score!=smallest And score!=largest):
               Print(score)
       Print(finalResult)

Define method MainLine:
   Scores[] = getsScores();
   Smallest = findMin(scores);
   Largest = findMax(scores);
   finalResult = truncatedMean(scores, smallest, largest);
   report(scores,finalResult,smallest,largest);

******* Thank You **********

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