64 634
Assignments Done
99,1%
Successfully Done
In September 2018

Answer to Question #4893 in Java | JSP | JSF for John Morales

Question #4893
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
Expert's answer
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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions