I basically know how functions work now but this problem is just confusing me.

Lowest Score Drop

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

-void getScore() should ask the user for a test score, store it in a reference parameter variable, and validate it. This function should be called by main once for each of the five test scores entered.

-void calcAverage() should calculate and display the average of the four highest scores. This function should e 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 it. It should be called by calcAverage, which uses the function to determine which of the five scores to drop.

Input Validation: DO not accept test scores lower than 0 or higher than 100.

...what I got out of that is to use the findLowest function to find the four highest scores and send them back to calcAverage where there they will be made into and average... how exactly do you do that?

I got started on it but got stuck on that part.

``````#include <iostream.h>
#include <iomanip.h>
#include <stdlib.h>

void getScore(int &);
void calcAverage(int &, int &, int &, int &, int &);
int findLowest(int &, int &, int &, int &, int &);

int main()

{
int num1, num2, num3, num4, num5;

cout << "This program finds the average of test scores where the " << endl;
cout << "lowest is dropped." << endl;

cout << "First Test:" << endl;
num1 = getScore();

cout << "Second Test:" << endl;
num2 = getScore();

cout << "Third Test:" << endl;
num3 = getScore();

cout << "Fourth Test:" << endl;
num4 = getScore();

cout << "Fifth Test:" << endl;
num5 = getScore();

calcAverage(num1, num2, num3, num4, num5);

return 0;

}

void getScore(int &score)
{
cout << "Enter a score." << endl;
cin >> score;

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

cout << "  Error: Do not enter scores less than zero or greater than ";
cout << "100" << endl;

exit(0);
}

}

void calcAverage(int &, int &, int &, int &, int &)

{

findLowest(num1, num2, num3, num4, num5);``````
3
Contributors
3
Replies
5
Views
7 Years
Discussion Span
Last Post by WaltP

You have posted everything except the findLowest function! What have you tried? I bet it should involve some conditionals (ifs) and some < operations.

o nvm I got it by looking at and older post, I should use the search box next time.