Find Lowest and Deduct

Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. For example: if the user enters the values 65, 43, 78, 67 and 64, the output will be:
After dropping the lowest test score, the test average is 68.50
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include <iostream>
using namespace std;

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

int main()
{
    double grade1, grade2, grade3, grade4, grade5;

    getScore(grade1);
    getScore(grade2);
    getScore(grade3);
    getScore(grade4);
    getScore(grade5);
    calcAverage(grade1,grade2,grade3,grade4,grade5);


}
void getScore(double &grade)
{
	static int count = 0;
	count++;
	cout << "Please enter in grade number " << count << ": ";
            cin >> grade;
            if ( grade < 0 || grade > 100 )
            {
                do
                {
	cout << "Please enter in a valid number 0 through 100: ";
                    cin >> grade;
                }
                while (grade < 0 || grade > 100 );
            }
}
void calcAverage(double score1, double score2, double score3, double score4, double score5)
{
    double lowest;
    double average;

    lowest = findLowest(score1,score2,score3,score4,score5);
    average = ((score1 + score2 + score3 + score4 + score5) - lowest) / 04;
    cout << "After dropping the lowest test score , the test average is " << average << endl;
}
int findLowest(double grad1, double grad2, double grad3, double grad4, double grad5)
{
    double average,
		   least,
		   lowDrop = 0;

    average = (grad1 + grad2 + grad3 + grad4 + grad5) / 5;
    cout << "The average before dropping the lowest grade:  " << average << endl;


    if(grad1 < 100)
	{
		least = grad1;
        lowDrop = grad1;
        return lowDrop;
	}
	else if(grad2 < 100)
	{
		least = grad2;
        lowDrop = grad2;
        return lowDrop;
	}
	else if(grad3 < 100)
	{
		least = grad3;
        lowDrop = grad3;
        return lowDrop;
	}
	else if(grad4 < 100)
	{
		least = grad4;
        lowDrop = grad4;
        return lowDrop;
	}
	else if(grad5 < 100)
	{
		least = grad5;
        lowDrop = grad5;
        return lowDrop;
	}

}



Mine withdraws the First number entered and If I enter 0 it doesn't even count it then takes it as there is only 3 entered
Perhaps something like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>

int main() {
	constexpr unsigned NoScores {5};
	constexpr int minScore {};
	constexpr int maxScore {100};
	double sum {};
	int low {maxScore + 1};

	std::cout << "Enter " << NoScores << " scores: ";

	for (unsigned n {}; n < NoScores; ++n) {
		int score {};

		do std::cin >> score;
		while ((score < minScore || score > maxScore) && (std::cout << "Please enter a valid number " << minScore << " through " << maxScore<< '\n'));

		if (score < low)
			low = score;

		sum += score;
	}

	std::cout << "Average of best " << NoScores - 1 << " scores is " << (sum - low) / (NoScores - 1) << '\n';
}

while yours works perfectly , I forgot to add.

It should use the following functions:
• An int function getScore with no parameters, to ask the user for a single test score, validate it and return the score. The function should be called by the main function once for each of the five scores to be entered. Do not accept test scores lower than 0 or higher than 100.
• An int function findLowest that is passed the five test scores and then finds and returns the lowest of the five scores passed to it. It is called by function calcAverage, to determine which of the five scores to drop.
• A float function calcAverage that is passed the five test scores and then calculates and returns the average of the four highest scores.
• A void function displayOutput that is passed the average score; it then displays the average of the test scores. Display two digits after the decimal point.
I have corrected it , it works now!
Topic archived. No new replies allowed.