JAVA PROGRAM: In competitive diving, each diver makes three dives of varying degrees of difficulty. Nine judges score each dive from 0 through 10 in steps of 0.5. The total score is obtained by discarding the lowest and highest of the judges' scores, adding the remaining scores, and then multiplying the scores by the degree of difficulty. The divers take turns, and when the competition is finished, they are ranked according to score. Write a program to calculate the outcome of a competition, using the following input and output specifications. Define Diver class and Judge class, and then write a Diving Competition application. Input 1. Number of divers 2. Diver's name (ten characters), difficulty (float), and judges' ratings (nine floats) 3. There is a line of data for each diver for each dive. All the data for Dive I are grouped together, then all for Dive 2, then all for Dive 3. Output 1. A table that contains the following information: Name Dive I Dive 2 Dive 3 Total where Name is the diver's name; Dive 1, Dive 2, and Dive 3 are the total points received for a single dive, as described above; and Total is the overall total.
What did you get and where did you have problems?
I was trying to use aggregation and array to solve the problem above. I am able to do the aggregation and array separately. but, I have some confusion in using both aggregation and array at the same time.
Well, aggregation is when some piece of data has another piece of data linked to it. Like if you have a list of employees. Every employee has a set of evaluations. However, you can't evaluate nobody. You can not have an evaluation without an employee. This is a critical part of how these links work. You can only attach an evaluation to an employee. You can not do the reverse or have an evaluation that stands alone. So you can do an array of employees. Inside each, it can have an evaluation or even an array of evaluations. Those evaluations are the aggregations. What you do is make an evaluation class. In it, you define the data to be stored in it. Then you make the employee class, which has an instance of the evaluation class in it. Finally, the main or some other part of the program has the array that instantiates the employees.
Join our real-time social learning platform and learn together with your friends!