In diving competitions each dive is assigned a numeric rating
by 5 different judges. Each dive also has a "degree of difficulty."
The score for the dive is obtained by
throwing out a highest and a lowest rating, and then multiplying the degree of
difficulty times the sum of the remaining three ratings.
Each rating must be a decimal number between 0.0 and 10.0 inclusive,
having exactly one digit to the right of its decimal point.
Furthermore, the digit to the right of the decimal point must be a 0 or a 5.
The degree
of difficulty must be between 1.0 and 4.0 inclusive and have exactly one digit
(possibly 0) to the right of its decimal point. Exactly 3 characters are
used to express the degree of difficulty and each rating, with the exception that a rating
of 10.0 uses 4 characters.
We know the score that our diver needs on her final dive to win a medal.
We know the degree of difficulty of her final dive. But when the ratings
appear on the scoreboard, one of the ratings appears as "?.?" due to an electronic
malfunction. What is the smallest legal rating from that judge that will result
in a medal?
Create a class Diving that contains a method needed that is given a
String difficulty, the degree of difficulty, a String need that is the score
needed for a medal expressed with exactly 2 digits to the right of its decimal point,
and a String ratings
containing the 5 ratings given to our diver except that one of them appears as "?.?". ratings will have no leading or trailing spaces and will have exactly one space between its 5 parts.
The method returns the smallest legal rating that would result in a medal for our diver, expressed as a String as described above. If no legal rating would give her a medal, return "-1.0".
|