Question

In: Computer Science

Create global variables Mean, Mode, Median, then create a method that takes an array of 10...

Create global variables Mean, Mode, Median, then create a method that takes an array of 10 double numbers and return three answers of the Mean, Median, Mode ( no need for implementation of the mean, median and mode, calculate them manually and return the answers), assign the answers to the global variables.

In java, please!!

Solutions

Expert Solution

The following is the code for above question. As it is stated in the question that there is no need to implement the logic for mean,median and mode, I just manually calculated for given array and assigned to global varibales. In java, inorder to declare a variable global, we have to declare it using static keyword at start of the code.

import java.util.*;
public class Main
{
    public static double Mean,Median,Mode;
        public static void main(String[] args) {
                double[] values = new double[]{2.5,4.42,5.2,2.1,6.2,3.4,5.9,6.1,9.3,2.5}; //double array of values
                calculate(values);
                System.out.println("Mean is "+Mean);
                System.out.println("Median is "+Median);
                System.out.println("Mode is "+Mode);
        }
        public static void calculate(double[] values)
        {
            Mean=4.084;
            Median=5.2;
            Mode=2.5;
        }
}

Output:

Mean is 4.084
Median is 5.2
Mode is 2.5


#Please dont forget to upvote if you find the solution helpful. Feel free to ask doubts if any, in the comments section. Thank you.


Related Solutions

Write a program that calculates the mean, median and mode of a given array in the...
Write a program that calculates the mean, median and mode of a given array in the following manner: i) Write three functions mean (), median () and mode () that calculates the mean, median and mode of an array. ii) Using these functions write a program that calculates all the three above mentioned values for two different arrays A and B where A is an array that contains the number of hours spent by a person each day for playing...
Determine the mean, median, and mode for each of the variables. What is the variance for...
Determine the mean, median, and mode for each of the variables. What is the variance for each set of data for each of the variables? What is the standard deviation for each of the variables? What is the probability that each event occurs in each of the two variables. Data: Time Stamp with questions with 3 multiple choice options Timestamp 1. If given the opportunity would you work from home? 2. Do you consider working from home more of a...
Mean , Median and Mode
The mean of 8,11,6,14,m and 13 is 11 a) Find the value of m. b) Find the median and mode of given data set.
Which measure of central tendency would you use for the following variables (mean, median or mode)....
Which measure of central tendency would you use for the following variables (mean, median or mode). Explain your choice. Gender: _______________________________________________________ Class rank at a college: __________________________________________________ Age of high school students: ________________________________________ A skewed income distribution (90% with incomes under $150K; a few with incomes of several million): ____________________________________________________ Which measure of central tendency would you use for the following variables (mean, median or mode). Explain your choice. Gender: _______________________________________________________ Class rank at a college: __________________________________________________ Age of high...
Create a small dataset of at least 5 observations and calculate the mean, median, mode, range,...
Create a small dataset of at least 5 observations and calculate the mean, median, mode, range, IQR and standard deviation (use Excel or StatCrunch). Add an outlier to your data and recalculate these measures. Which changed and by how much? Explain how this illustrates the idea of resistant measures. Please provide the data that you made up and the measures for your data before and after you added an outlier. Organizing the data into a table would be a great...
In java we will need to create a method that takes the array {1,2,3,4,5} and returns...
In java we will need to create a method that takes the array {1,2,3,4,5} and returns the head reference to a linkedList. We will also need to display the linked list in out main method.
Find the mean, median, and mode of the following set of data. (Enter solutions for mode...
Find the mean, median, and mode of the following set of data. (Enter solutions for mode from smallest to largest. If there are any unused answer boxes, enter NONE in the last boxes.) (a) 6 6 7 8 9 12 Mean Median Mode Mode (b) 6 6 7 8 9 108 Mean Median Mode Mode
how do i interpret mean, mode and median?
how do i interpret mean, mode and median?
For the following distribution find the mean, median, mode, range and standard deviation: 13, 10, 16,...
For the following distribution find the mean, median, mode, range and standard deviation: 13, 10, 16, 20, 10, 14, 13, 25
Why Mean, Median and Mode are called centrality measurements? Provide an example in which the Median...
Why Mean, Median and Mode are called centrality measurements? Provide an example in which the Median is a better indicator than the Mean Why Range, Mean Average Deviation, Variance and Standard Deviation are called Dispersion Measurements
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT