# Question-   write a program that calculates the average of a group of test scores

Solution-

Question:- Write a C++ program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should have the following functions:

void getScore() should read a score from the file and store it in reference parameter variable. This function should be called by main once for each of the five scores to be entered.
void calcAverage() should calculate and display the average of the four highest scores. This function should be called just once by main, and should be passed the five scores.
int findLowest() should find and return the lowest of the five scores passed to it. It should be called by calcAverage, which uses the function to determine which of the five scores to drop.

Complete solution below:-

``````

#include<stdio.h>

#include<iostream>

#include<iomanip>

#include<stdlib.h>

using namespace std;

// Prototypes of the functions used in the programs

void getScore(int&);

void calcAverage(int, int, int, int, int);

int findLowest(int sc1, int sc2, int sc3, int sc4, int sc5);

//Main Function .Excution start here..

int main(){

int sc1, sc2, sc3, sc4, sc5;

getScore(sc1);

getScore(sc2);

getScore(sc3);

getScore(sc4);

getScore(sc5);

calcAverage(sc1, sc2, sc3, sc4, sc5);

system("pause");

return 0;

}

void getScore(int &score){

cout << " Please.. Enter a Score between (0 - 100):= ";

cin >> score;

while (score < 0 || score > 100){

cout << "Sorry Error - Enter a score between (0 - 100):= ";

cin >> score;

}

}

//there are five values use to get lowest value

int findLowest(int sc1, int sc2, int sc3, int sc4, int sc5){

int lowestVal = sc1;

if (sc2 < lowestVal)

lowestVal = sc2;

if (sc3 < lowestVal)

lowestVal = sc3;

if (sc4 < lowestVal)

lowestVal = sc4;

if (sc5 < lowestVal)

lowestVal = sc5;

cout << "\n The Lowest Score is:+ " <<" \" "<< lowestVal <<" \" " << endl;

return lowestVal;

}

//Calculate the value of average of scores

void calcAverage(int sc1, int sc2, int sc3, int sc4, int sc5){

int lowestVal = findLowest(sc1, sc2, sc3, sc4, sc5);

double averageVal = (((float)sc1 + sc2 + sc3 + sc4 + sc5) - lowestVal) / 4.0;

cout << setw(4);

cout << fixed << showpoint << setprecision(2);

//print average

cout << "\n The Average of the Highest Scores is := " << averageVal << endl;

}
```
```

# Our happy customers

They are fast in responding to homework questions. they have the best technical writers. Thanks for helping me with my programming doubts.

Dyana
5

I contact to disklib for homework, they help me out, despite there was some technical issue they gone through extra mile for me and provide me good quality work in first priority. 100% recommended.

Asif Waheed
5

Desklib's study resources are best & unique. Their study database is easy to access and easy to use.
100 % recommended.

Mike Taylor
5