Well, first of all, I would just like to say that I have half of the program right (at least I think that i have it right).
My program is supposed to do three things:
- 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.
- voidcalcAverage()-should calculate and display the average of the four highest scores. This function should be called just once by main, and should be passed the five scores
- int findLowest()-shoudl find and return the lowest of the five scores pased to it. It should also be called by calcAverage, who uses the function to determine which of the five scores to drop
Code:
#include <iostream>
#include <conio>
using namespace std;
//Function prototype
void getscore(int&, int&, int&, int&, int&);
void findLowest (int, int, int, int, int, int);
void calcAverage (double)
int main()
{
int LO, score1, score2, score3, score4, score5;
getscore (score1, score2, score3, score4, score5);
findLowest(LO, score1, score2, score3, score4, score5);
getch();
return 0;
}
void getscore (int &score1, int &score2, int &score3, int &score4, int &score5)
{
cout << "Enter first score: ";
cin >> score1;
cout << "Enter second score: ";
cin >> score2;
cout << "Enter third score: ";
cin >> score3;
cout << "Enter fourth score: ";
cin >> score4;
cout << "Enter fifth score: ";
cin >> score5;
}
int findLowest(int LO, int score1, int score2, int score3, int score4, int score5)
{
if((score1<score2)&&(score1<score3)&&(score1<score4)&&(score1<score5))
{
LO=score1;
cout << LO;
}
else if((score2<score1)&&(score2<score3)&&(score2<score4)&&(score2<score5))
{
LO=score2;
cout <<LO;
}
else if((score3<score1)&&(score3<score2)&&(score3<score4)&&(score3<score5))
{
LO=score3;
cout << LO;
}
else if((score4<score1)&&(score4<score2)&&(score4<score3)&&(score4<score5))
{
LO=score4;
cout << LO;
}
else if((score5<score1)&&(score5<score2)&&(score5<score3)&&(score5<score4))
{
LO=score5;
cout << LO;
}
}
But, now I am having trouble with the void calcAverage() part. this function should calculate and display the average of the four highest scores. This function should be called once by main, and should be passed the five scores.
Does anyone have any idea how to do that