for my assignment I was told I have to use a function at one point. The one I put in doesn't work properly. Any help?
[code=cpp]
//variable declaration
float score[7]; //declares an erray of 8 float values
int s=0;
float sum=0;
int i = 0;
int n=0;
int position = 0;
float Max = 0;
for (i=0; i<=7; i++){
cout << "Please enter each one of the eight judges scores and press enter after each one" << end$
cin >> score[i];
}
float Min = score[0];
for (n=1; n<=7; n++) {
if (Min> score[n]){
Min = score[n];
position = n;
}
}
cout << fixed<< showpoint << setprecision(2) << endl;
cout <<"Min number is " << Min << endl;
Max = score[0];
position = 0;
for (n=1; n<=7; n++){
if (Max < score[n]) {
Max = score[n];
position = n;
}
}
cout <<"Max number is " << Max << endl;
for (s=0; s<=7; s++)
{
sum = sum + score[s];
}
cout <<"Original sum " << sum << endl;
sum = sum - Min - Max;
cout << fixed<< showpoint << setprecision(2) << endl;
cout << "The point received by the diver are: " << score[2] << endl;
[/code]
[code=cpp]
//variable declaration
float score[7]; //declares an erray of 8 float values
int s=0;
float sum=0;
int i = 0;
int n=0;
int position = 0;
float Max = 0;
for (i=0; i<=7; i++){
cout << "Please enter each one of the eight judges scores and press enter after each one" << end$
cin >> score[i];
}
float Min = score[0];
for (n=1; n<=7; n++) {
if (Min> score[n]){
Min = score[n];
position = n;
}
}
cout << fixed<< showpoint << setprecision(2) << endl;
cout <<"Min number is " << Min << endl;
Max = score[0];
position = 0;
for (n=1; n<=7; n++){
if (Max < score[n]) {
Max = score[n];
position = n;
}
}
cout <<"Max number is " << Max << endl;
for (s=0; s<=7; s++)
{
sum = sum + score[s];
}
cout <<"Original sum " << sum << endl;
sum = sum - Min - Max;
cout << fixed<< showpoint << setprecision(2) << endl;
cout << "The point received by the diver are: " << score[2] << endl;
[/code]
Comment