Function help

So I am having trouble defining the functions getTestScore and calcAverage on this program. Commented into the program are instructions on what I'm trying to do.
This is what I have so far, anything to point me in the right direction would be helpful.
Thanks.

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
  #include <iostream>
using namespace std;
//function prototypes
float getTestScore();
float calcAverage(float score1, float score2, float score3);
int main()
{
	float s1, s2, s3; //these variables are used to store test scores
	float average;
	//call getTestScore function to get the test scores
	s1 = getTestScore();
	s2 = getTestScore();
	s3 = getTestScore();
	//call calcAverage to calculate the average of three test scores
	average = calcAverage(s1, s2, s3);

	//display the average
	cout << "average of three test scores(" << s1 << "," << s2 << "," << s3 << ")is" << average << endl;
	return 0;
}
//function definitions/implementation getTestScore function gets a test score from the user and
//validates the score to make sure the value is between 0 and 100. if score is out of range
//getTestScore function allows the user to re-enter the score. This function returns a valid score
// to the caller function
float getTestScore()
{
	float score = 0;
	do
	cout << "Enter test score: " << endl;

	{while (score >= 0 && score <= 100);

		cin >> score;
	}
		
		return score;
	


	

	// calcAverage function calculates and returns the average of the      three  test scores passed to
	//the function as input.
	float calcAverage(float score1, float score2, float score3);
	{
		float average;
		average = (score1 + score2 + score3) / 3;
		cout << "The average is" << average << endl;
		return average;
	}

Lines 28-34: Your do/while is malformed.
1
2
3
4
5
	do
	{	cout << "Enter test score: " << endl;
		cin >> score;
	}
	while (! (score >= 0 && score <= 100));

Line 37: You're missing a close brace.
Line 44: Get rid of the ;
Thank you! You are the man.
Topic archived. No new replies allowed.