Hi All ~ So the program actually compiles without using arrays or global variables, outputs the correct user input, however average score and lowest score values that compute are wrong. I have no idea where the heck I'm messing up but I am hoping you can help me.

The findLowest module works in that it outputs the last number entered by the user. calcAverge outputs the average of the last score alone. I guess I need to know where to put the accumulator for calcAverage and whether I should take a different approach altogether.

I am soooooo.....close to having this program work...*sigh*

Thank you for any help!:)

#include <iostream>
using namespace std;

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

int main ()
{
	int refscore;
	
	getScore(refscore);
	findLowest(refscore);
	calcAverage(refscore);
				

	cout << "The lowest score is: " << findLowest(refscore) << "\n" << endl;


	system("pause");
	return 0;
}

void getScore(int &refscore)
{
	

		cout << "Please enter a test score: ";
		cin >> refscore;
		refscore = findLowest(refscore);
		
			if(refscore >= 0 && refscore <= 100)
			{
				for(int count = 1; count <= 4; count++)
				{
					cout << "Please enter a test score: ";
					cin >> refscore;
					
						int total = refscore;
						total++;
					
				}
				
				
			}
		
	
			if(refscore < 0 || refscore > 100)
			{

				cout << "Invalid Entry. Please enter a test score ";
				cout << "between 0 and 100. \n" << endl;
			}

			refscore = findLowest(refscore);
		}




int findLowest(int refscore)
{

	int lowest = -1;



	if(lowest >= refscore)
			refscore = lowest;
		

	return refscore;
}

void calcAverage(int refscore)
{
	int total = 0; //accumulator
	int average;


	average = ((findLowest(refscore)) - total)/4;

		cout << "The average score is: " << average << "\n" << endl;

}

Recommended Answers

All 5 Replies

I think you're missing some program code, and tell us exactly what problems you are experiencing, and also what you're trying to accomplish.

I think you're missing some program code, and tell us exactly what problems you are experiencing, and also what you're trying to accomplish.

Right sorry about that. Writing a modular function program that does not use arrays or global vars - calculates the average of five test scores after the lowest score is dropped.

I am not looking for the answer ~ just a shove in the right direction. It looks like findLowest is not recognizing all of the scores passed through it and olny recognizing the last comparison.

You can make a variable in findLowest static. Sorry for the delay, busy as usual.

You can make a variable in findLowest static. Sorry for the delay, busy as usual.

Thanks. I'll try that next. Had a static var in there and someone said I should take it out. Right now it looks like I am missing a bit of code but also - things are not in the right order in each function.

I really hope I'm not the only beginning programmer to go through this...argh.

Still working it but marking this thread as solved. Thanks for the help you did give.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.