Drop Lowest, Calculate Average

I'm supposed to write a program with 3 functions included to ask for five test scores, find the lowest of the test scores and drop it, then calculate the average. I've made it able to compile but the values aren't working correctly, I'm getting an incorrect average but am not sure what I need to do to fix it.

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
  #include <iostream>
#include <iomanip>
using namespace std;

double getValues();
double findLowest(double, double, double, double, double);
void calcAverage(double,double,double,double,double,double);

int main()
{
	int score1,score2,score3,score4,score5;
	int lowest;
	double average;
	cout<<fixed<<showpoint<<setprecision(2);
	
	cout<<"This program will ask for five test scores,"<<endl;
	cout<<"drop the lowest score, then calculate the average."<<endl;
	score1=getValues();
	score2=getValues();
	score3=getValues();
	score4=getValues();
	score5=getValues();
	
	lowest=findLowest(score1,score2,score3,score4,score5);
	calcAverage(score1,score2,score3,score4,score5,lowest);
	
	return 0;
}

double getValues()
{
	double score;
	
	cout<<"Enter the test score: ";
	cin>>score;
	return score;
}
double findLowest(double score1,double score2,double score3,double score4,double score5)
{
	double lowest;
	lowest=score1;
	
	if(score2<lowest)
		lowest=score2;
	else if(score3<lowest)
		lowest=score3;
	else if(score4<lowest)
		lowest=score4;
	else if(score5<lowest)
		lowest=score5;
		
return lowest;
}
void calcAverage(double score1,double score2,double score3,double score4,double score5, double lowest)
{
	double average;
	average=(score1+score2+score3+score4-lowest)/4;
	cout<<"The average of the test scores with the lowest dropped is "<<average<<endl;
}
Line 57: Since you're subtracting lowest, don't you want to add in score5?
if your subtracting the lowest number from all five scores, dont you want to add all five numbers together first?

line 57 = average=(score1+score2+score3+score4+score5-lowest)/4;
Get rid of the elses in findLowest(). As written, if score2 < lowest then it will never even check the other scores to see if one of them is lower.
Thanks for the help! I see what I did wrong now.
Topic archived. No new replies allowed.