Answer to Question #4893 in Java | JSP | JSF for John Morales
Create a method called avgValue, which takes an array of doubles as an input parameter and returns the average value of the entries in the array.
Example:
data1:{1.1,2.5,3.0}
==> 2.2
1
2011-10-27T10:35:53-0400
public class AvrValue {
public static double avrValue(double[] arr)
{
double sum = 0;
for (double d : arr)
sum += d;
return sum /
arr.length;
}
public static void main(String[] args)
{
System.out.println(avrValue(new double[] { 1.1, 2.5, 3.0
}));
}
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
JavaJSPJSF
Comments
Leave a comment