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;
}