Lab 4: Mean, median, mode

Due Date and Submission Requirements


The goal of this lab is:


Background and Directions

Using Lab4Demo.Java, you will fill in the methods to get the desired output seen below. You need to write the three following methods. You do not need to define any other classes or methods. You are not allowed to import any additional libraries

  • calculate_mean() should take in an integer array, calculate the mean of the dataset and print it out. The mean is the average of all the numbers in the list
  • calculate_median() should take in an integer array, calculate the median of the dataset and print it out in. The median is the middle value of the sorted integer list. If there is no definite middle value, it will be the average between the two middle values.
  • calculate_mode() should take in an integer array, calculate the mode of the dataset and print it out. The mode is the number that occur the most in the list. Your program only needs to find one mode value. You can assume that there will always be at least one mode value.

  • You can assume that the numbers in the array will only be between 1-100, but your methods should work on arrays of any size (>0)
  • Starting Code

    Required Output

    When your program is run, your output should look exactly the same as seen in this screenshot . If your median is a double, and not an int in some cases (ie 27.0 vs 27), that is fine!

    Grading (10 points)