program does not work:
Assignment:
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 to store each Judge’s score
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 scores .
*** 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
Scores = 5 4 3 2 1 6 7
Difficulty level = 1.2
Total score = 14.4
My program:
#include<iostream>
using namespace std;
int main()
int score[7];
double difficulty;//1.2 to 3.8
double Total ;
// start loop
cout << "Enter the difficulty level (1.2 - 3.8):";
cin >> difficulty;
for( unsigned int i = 0; i < 7; i++ )
std::cout << "Enter the score of judge " << i+1 << ": " << std::flush;
std::cin >> score[i];
{
for (unsigned int i=0, Total=0; i < 7; i++)
Total += score [i] ;
}
// display output end loop
cout << "Scores = " << score << endl;
cout<< "Total score = "<< Total*0.6 << endl;
system("PAUSE");
return 0;
}