Results 1 to 3 of 3
Thread: Median and mode HELP!
- 10-09-2012, 04:52 AM #1
Member
- 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; 10-09-2012 at 05: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.
If you need our help, you'll need to post your code, tell us about your errors, etc. We're terrible at guessing at these things.p.s. I already spent 5 hours on trying to make it work but it won't.
- 10-09-2012, 06:14 AM #3
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
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: 05-16-2012, 10:36 PM -
Finding the Median
By system5634 in forum New To JavaReplies: 1Last Post: 02-07-2012, 01:30 PM -
Calculating Median and mode
By rochla16 in forum New To JavaReplies: 4Last Post: 04-29-2011, 04:24 AM -
Finding Median of X Integers
By Hasan in forum New To JavaReplies: 3Last Post: 08-12-2008, 02:06 PM -
Quick sort with median-of-three partitioning
By Java Tip in forum AlgorithmsReplies: 0Last Post: 04-15-2008, 07:40 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks