I'm getting errors that I don't know how to fix. Please Help!!!

I'm getting a few errors that I am not sure how to fix. Any help would be greatly appreciated. Thank you.

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

int getScore(int, int, int, int total);
double calcAverage( int, int);
int findLowest(int scoreArray [5])

int main()

{
	int scoreArray[5];
	int testScore = 0;
	double avg = 0.0;
	int lowest = 0;
	int i;
	double total;

	for (int i = 1; i <=5; i++)
	{
		testScore = getScore(testScore, i , total);
		scoreArray[i-1] = testScore;
	}
	
	
	lowest = findLowest(scoreArray);
	avg = calcAverage(lowest, total);

	cout << "\nThe lowest score dropped was: "<< lowest << endl;
	cout << " The average is " <<setprecision(2) << fixed << avg;
	
	return 0;
}
double calcAverage ( int lowest, int total)
{
	int sumOfFour = 0;
	float avg = 0.0f;

	sumOfFour = total - lowest;
	avg = sumOfFour / 4.0f;
	return avg;
}
	
	
	
	int findLowest( int scoreArray[5])
	{
		int smallest = scoreArray [0];
		for (int i = 1, i < 5, i++)
		{
			if (scoreArray[i] < smallest)
				smallest = scoreArray[i];
		}
		return smallest;
	}

	int getScore (int testScore, int i, double total)
	{
		cout <<"Please enter your score for exam" << i;
		cin >> testScore;
	}
	
	{
	while (testScore < 0 || testScore > 100)
	
		cout <<"Please enter a valid score. Try Again."<< endl;
		cin >> testScore;
	
	}

	total += testScore;
	
	
	return testScore;
Hey. Please provide the errors next time :)

int findLowest(int scoreArray [5]) // You forgot the semicolon


1
2
3
int getScore(int, int, int, int total); // this function takes 4 integers right?

testScore = getScore(testScore, i , total); // Here you only pass 2 stuff. 


int findLowest(int scoreArray [5]) // Remvove the number 5, you cant do that. Remove it from the definition aswell, if you want to send in the size send it in as an integer separately


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
int getScore (int testScore, int i, double total)
	{
		cout <<"Please enter your score for exam" << i;
		cin >> testScore;
	}
	
	{
	while (testScore < 0 || testScore > 100)
	
		cout <<"Please enter a valid score. Try Again."<< endl;
		cin >> testScore;
	
	}

	total += testScore;
	
	
	return testScore;


The while loop and everything after is outside the function, you most likely want them inside.

1
2
3
for (int i = 1, i < 5, i++) // You seperate them by semicolon, not colon.

for(int i = 1; i < 5; i++) // like that 
Last edited on
Thank you for your help. I am still having one more issue with this.


for (int i = 1, i < 5, i++)


I keep getting an error with line #49
Read the bottom of my post more carefully^^

Edit: Just at tip though, you could have just easily googled "c++ for-loops" to figure out what was wrong with it.
Last edited on
I just seemed to have overlooked it. I am in way over my head with this class. This is very difficult to me. I do have just one more with this program . I keep getting an error.





int getScore(int, int, int, int total); // this function takes 4 integers right?

testScore = getScore(testScore, i , total); // Here you only pass 2 stuff.



I don't know how to fix this to make it work.
Oh I didint look too clearly, it takes 4 arguments, but you're only sending in 3. If you are sure you only want to send in testcore, i and total. Then remove the 4th one from the protoype so it looks like this

int getScore(int, int, double total);

And where you write the actual function it should look identical.
int getScore(int, int, int, int total);
base on your program, you just mistyped this
try to write it like this
int getScore(int, int, int total);
int getScore(int, int, double total); // total has to be double not int
Topic archived. No new replies allowed.