Hi ~ As you can see from the code below I am in school for programming. I have come across this homework assignment a few times on the site already however the requirements for mine are different. I cannot use arrays.
Three functions - I only have two coded. The void calcAverage prototype is not causing an error and the program compiles and runs asking the using for the five test scores with no problem.
I cannot find the error in passing the 'lowest' score value. Upon the user (me) entering the five scores, the lowest score value is always 0.
I have been working on this darn thing for a week and a half, think I have it figured out but this is stumping me. Why the heck isn't my lowest score of five entered showing on output? I have not added the third function because I wanted to test this first.
Any help will be very appreciated!!
Thanks!
#include <iostream>
using namespace std;
void getScore (int &);
int findLowest (int);
void calcAverage(int);
int main ()
{
static int refscore, lowest;
for(int count = 1; count <= 5; count++)
{
getScore(refscore);
int findLowest(lowest);
}
cout << "The lowest score is: " << lowest << endl;
system("pause");
return 0;
}
void getScore(int &refscore)
{
if(refscore >= 0 && refscore <= 100)
{
cout << "Please enter a test score: ";
cin >> refscore;
}
if(refscore < 0 || refscore > 100)
{
cout << "Invalid Entry. Please enter a test score ";
cout << "between 0 and 100. ";
cin >> refscore;
}
}
int findLowest(int lowest)
{
static int refscore;
getScore(refscore);
lowest = refscore;
if(refscore > lowest)
lowest = lowest;
return lowest;
}