Hi everyone, I'm relatively new at C++ - knowning most of the basic rules and various structures of a C++ program - but I'm having a hard time developing a code - without the use of an arry (haven't learned it yet) - that determines the lowest number and drops it when calculating the average of a set of numbers. Here's the question:
"Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions:
void getScore() - should ask the user for a test score, store it in a reference parameter variable, and validate it. This function should be called by main once for each of the five scores to be entered.
void calcAverage() should calculate and display the average of the four highest scors. This function should be called just once by main, and should be passed the the five scores.
int findLowest() should find and return the lowest of the five scores passed to it. It should be called by calcAverage, who uses the function to determine which of the five scores to drop.
* Do not accept test scores lower than 0 or higher than 100."
This is what I have so far:
I know how to write the code for calculating, calling other functions, etc., but I'm stuck at how to write a code that finds the lowest test score - inputed by the user - and drops it. I think I may need to edit how I did the for statement, but not really sure.
//#4: Lowest Score Drop
using namespace std;
sum = 0,
cout <<"This program will calculate the average of five test scores, where the" << endl;
cout <<"lowest score in the group is dropped." << endl;
for(count = 1; count <= 5; count++)
cout <<"Please enter the score for test " << count <<"." << endl;
cin >> testScore;
if(testScore < 0 || testScore > 100) // Checks to see if input is valid:
//0 <= testScore <= 100
cout << testScore << " is invalid. Please enter a score that is greater" << endl;
cout <<"than or equal to 0 or less than or equal to 100." << endl;
break; // breaks out of if statement
sum += testScore;
cout <<"Do you wish to restart the program?(y/n)" << endl;
cin >> restartProgram;
}while(restartProgram == 'y' || restartProgram == 'Y');
//Continue rest of program later...
system("pause"); //used for Dev C++