This is what I'm working on. I got some of the code but it don't seem to work right. I dont know how to sort the array out to subtract the highest and lowest numbers.
In the sport of diving, seven judges award a score between 0 and 10, where each score may be a floating-point value. The highest and lowest scores are thrown out and the remaining scores are added together. The sum is then multiplied by the degree of difficulty for that dive. The degree of difficulty ranges from 1.2 to 3.8 points. The total is then multiplied by 0.6 to determine the diver’s score.
Write a computer program that inputs a degree of difficulty and seven judges’ scores, and outputs the overall score for that dive. The program should ensure that all inputs are within the allowable data ranges. To make your programming easier, if a number is out of range (greater than the upper limit or less than the lower limit), then let the program replace it with upper or lower limit numbers.
Hint: Use double Array and for loop statement
Hint: Use highest variable with the initial value of 0, and lowest variable with the initial value of 10, in order to find out the highest and the lowest values.
*** sample output
Please enter the difficulty level(1.2 - 3.8): 1
Enter the score of judge 1: 5
Enter the score of judge 2: 4
Enter the score of judge 3: 3
Enter the score of judge 4: 2
Enter the score of judge 5: 1
Enter the score of judge 6: 6
Enter the score of judge 7: 7
I don't think that std::sort works like this. You should use a syntax like:
1 2 3
vector<double> vscore(score, score+7); //intialize a vector with your array
vector<double>::iterator it; //declare an iterator
sort (vscore.begin(), vscore.end()); //sort the values.
Now you can calculate the sum of sorted values minus the two extremes:
1 2 3 4
double sum;
vector<double>::size_type sz = vscore.size();
for (i=1; i<sz-1; i++)
sum += vscore[i];