• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Java programming help?

MournSanity

Diamond Member
I made a program that accepts some floating point numbers and adds them to a 10 number array. I am trying to figure out how to determine the mode and median of the numbers in this array. Does anybody have any pointers or tips of how to write a method that determines the median and mode?

Thanks in advance.
 
Median, you can sort the array first and then do what you normally do to find the median.

Before I can give advice for a mode, is there a maximum value that is allowed in the array?
 
mode:

Iterate through the (sorted) array and count how many numbers in a row are the same. If that number is greater than the old "most in a row" save the new number, continue to the end of the array.
 
Back
Top