Results 1 to 3 of 3
  1. #1
    Gamedisolver is offline Member
    Join Date
    Oct 2012
    Posts
    3
    Rep Power
    0

    Exclamation 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 failed
    Last edited by Gamedisolver; 10-09-2012 at 05:06 AM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: Median and mode HELP!

    Quote Originally Posted by Gamedisolver View Post
    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.
    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.
    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.

  3. #3
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default 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

  1. Quicksort median
    By louboulos in forum New To Java
    Replies: 6
    Last Post: 05-16-2012, 10:36 PM
  2. Finding the Median
    By system5634 in forum New To Java
    Replies: 1
    Last Post: 02-07-2012, 01:30 PM
  3. Calculating Median and mode
    By rochla16 in forum New To Java
    Replies: 4
    Last Post: 04-29-2011, 04:24 AM
  4. Finding Median of X Integers
    By Hasan in forum New To Java
    Replies: 3
    Last Post: 08-12-2008, 02:06 PM
  5. Quick sort with median-of-three partitioning
    By Java Tip in forum Algorithms
    Replies: 0
    Last Post: 04-15-2008, 07:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •