Results 1 to 3 of 3
Thread: Median and mode HELP!
 10092012, 05:52 AM #1Member
 Join Date
 Oct 2012
 Posts
 3
 Rep Power
 0
Median and mode HELP!
Ok so my math final is due tomorrow and part of it is i have to get a user input for 10 numbers and find the median and mode. I need Them to be in separate classes. I need The median needs to be able to have two answers and find the average of them them. Mode has to be able to have 2 answer example: 2344214978.
p.s. I already spent 5 hours on trying to make it work but it won't.
I dont have much code at all.
Meadian
import java.util.Arrays;
public class median {
public static void main(String[] a){
int[] numbers = {9, 4, 6, 2, 1, 8, 7};
printNumbersInOrder(numbers);
}
public static void printNumbersInOrder(int[] numbers){
Arrays.sort(numbers);
for(int i = 0; i < numbers.length; i++)
System.out.println(numbers[i]);
}
}
this code just orders it
i have nothing for median anymore I was trying to use a bunch if if statments but that really failedLast edited by Gamedisolver; 10092012 at 06:06 AM.

Re: Median and mode HELP!
I think I speak for all in saying that you have our full permission to do this, and we wish you godspeed on your success.
p.s. I already spent 5 hours on trying to make it work but it won't.
 10092012, 07:14 AM #3Moderator
 Join Date
 Feb 2009
 Location
 New Zealand
 Posts
 4,716
 Rep Power
 17
Re: Median and mode HELP!
Why did you sort your array?
I guess I'm really asking what your plan of attack is to find the median. It is really important to have such a plan (aka algorithm) quite precisely fixed in you mind (and be able to express it to others) before you start writing code. Otherwise you run the risk of thrashing about fighting the compiler errors but not really knowing whether you're making progress.
Similar Threads

Quicksort median
By louboulos in forum New To JavaReplies: 6Last Post: 05162012, 11:36 PM 
Finding the Median
By system5634 in forum New To JavaReplies: 1Last Post: 02072012, 02:30 PM 
Calculating Median and mode
By rochla16 in forum New To JavaReplies: 4Last Post: 04292011, 05:24 AM 
Finding Median of X Integers
By Hasan in forum New To JavaReplies: 3Last Post: 08122008, 03:06 PM 
Quick sort with medianofthree partitioning
By Java Tip in forum AlgorithmsReplies: 0Last Post: 04152008, 08:40 PM
Bookmarks