Lab 4: Mean, median, mode
Due Date and Submission Requirements
- Due Date: Thursday, September 19th at 11:59 p.m.
- Partner Information: This is an individual assignment. You are allowed to collaborate with other students, but each student must submit their individual, independent solution.
- Submission Instructions: Upload your solutions (.java file), entitled Lab4Demo.java, to the BrightSpace(D2L) Lab 4 Dropbox.
The goal of this lab is:
- Gain experience using arrays and loops
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)
- 3 points - calculate_mean is correct
- 3 points - calculate_median is correct
- 4 points - calculate_mode is correct