Write a java program which contains the following static methods.You may not use
ID: 3642420 • Letter: W
Question
Write a java program which contains the following static methods.You may not use existing methods provided by Java but you may invoke methods in this MyStatistics class. For example, you may use findMax and findMin to derive your range value for the findRange method.
public static double findMedian(int[] numbers)
To find the median, first sort the values in order (You may use the sort method from the Arrays class provided by Java.) Check out the API page for its usage, and then follow one of these two procedures:
If the number of values is odd, the median is the number located in the exact middle of the array.
If the number of values is even, the median is found by computing the mean of the two middle numbers in the sorted array.
public static double findSTD(int[] numbers)
STD stands for standard deviation**so find the standard deviation of the array name numbers
Explanation / Answer
import java.util.*; public class Random { public static double findMedian(int[] numbers) { Arrays.sort(numbers); int l = numbers.length; if(numbers.length % 2 == 0) return (numbers[l/2] + numbers[l/2-1])/2.0; else return numbers[l/2]; } public static double findSTD(int[] numbers) { double average = 0; double std = 0; double deviations = 0; for(int i=0; iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.