in Jave create two methods work(), and interwork() with the follow instructions: You may assume that the work() method is passed a List that does not contain any null elements. (Note: The List may contain missing elements.) The work() method must not have any side effects. That is, it must not change the parameters that it is passed in any way and it must not change any attributes in any way. The work() method must return the weighted average of the elements in the List it is passed. The label of the result must equal the parameter named rl. The data parameter contains the values to use in the calculation. If an element of data is missing (i.e., has a value attribute that is null) then that element must be ignored in the calculation. The weights attribute contains the weights to use in the calculation. If the weights attribute is null then all weights used in the calculation must be 1. You may assume that all of the elements of weights (if it is non-null) are non- negative. If there is no weight associated with a label in an element of data then a weight of 0 must be used in the calculation for that element. 5. The work() method must use the interwork() method. 6. The interwork() method must calculate the numerator and the denominator used in the calculation of the weighted average in a fashion that is consistent with the specifications for the work() method. 6.1. It must return the numerator.
in Jave create two methods work(), and interwork() with the follow instructions:
-
You may assume that the work() method is passed a List that does not contain any null elements. (Note: The List may contain missing elements.)
-
The work() method must not have any side effects. That is, it must not change the parameters that it is passed in any way and it must not change any attributes in any way.
-
The work() method must return the weighted average of the elements in the List it is passed.
The label of the result must equal the parameter named rl. The data parameter contains the values to use in the calculation.
-
-
If an element of data is missing (i.e., has a value attribute that is null) then
that element must be ignored in the calculation.
The weights attribute contains the weights to use in the calculation.-
If the weights attribute is null then all weights used in the calculation must be 1.
-
You may assume that all of the elements of weights (if it is non-null) are non-
negative.
-
If there is no weight associated with a label in an element of data then a
weight of 0 must be used in the calculation for that element.
5. The work() method must use the interwork()
method.
6. The interwork() method must calculate the numerator and
the denominator used in the calculation of the weighted average in a fashion that is consistent with the specifications for the work() method.
6.1. It must return the numerator.
6.2. It must store the denominator in the attribute named denominator.
skeleton code for work:
public Object work(String s, Object<T> g)
{
return null;
}
Step by step
Solved in 2 steps with 4 images