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

The program is to calculate the average of a series of test scores, where the lo

ID: 3563260 • Letter: T

Question

The program is to calculate the average of a series of test scores, where the lowest score in the series is dropped. It should use the following functions: void getScores() should ask for five test scores and then store them in variables. This function should be called by main once for each of the five scores to be entered. int findLowest should determine which of the five scores is the lowest and return that value. It should be called by calcAverage, which uses the function to determine which of the five scores to drop. void calcAverage should calculate and display the average of the four high scores. It should be called once by main, and should be passed the five scores.

I need help with this in c++

Explanation / Answer

#include <iostream>

using namespace std;

void getScores(int& score){
    cout<<"Please Enter the score : ";
    cin>>score;
    cout<<score<<endl;
}

int findLowest(int A[], int size){
    int lowest=A[0];
    int i;
    for(i=1;i<size;i++){
        if(A[i] < lowest) lowest = A[i];
    }
    return lowest;
}

void calcAverage(int A[], int size){
    int drop = findLowest(A,size);
    int sum = 0,i;
    for(i=0;i<size;i++){
        sum += A[i];
    }
    sum -= drop;
    cout<<"Average is "<<(double)(sum/4.0)<<endl;
}

int main()
{
    int A[5];
    int i;
    for(i=0;i<5;i++){
        getScores(A[i]);
    }
    calcAverage(A,5);
    return 0;
}


//Sample output