Results 1 to 5 of 5
Like Tree2Likes
  • 2 Post By kjkrum

Thread: i need help with a program

  1. #1
    rascal is offline Member
    Join Date
    Apr 2013
    Posts
    2
    Rep Power
    0

    Default i need help with a program

    a program that takes 10 numbers as input and displays the median and the mode for this list of numbers. Your program should use parallel arrays and a method that takes as array of numbers as a parameter and returns the value of the mode for that list of numbers in the array. In addition, your program should use parallel arrays and a method that takes as array of numbers as a parameter and returns the value of the median for that list of numbers in the array.

  2. #2
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: i need help with a program

    We're not going to do your homework for you. Try doing it yourself first, and post your code if you have specific questions.
    SurfMan and JosAH like this.
    Get in the habit of using standard Java naming conventions!

  3. #3
    rascal is offline Member
    Join Date
    Apr 2013
    Posts
    2
    Rep Power
    0

    Default Re: i need help with a program

    ok i been working on it this is what i have i just need help on the math part


    package g;

    import java.util.*;
    import java.io.*;
    public class i
    {
    public static void main(String[]args) throws IOException
    {
    BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
    ArrayList all = new ArrayList();
    ArrayList median = new ArrayList();
    ArrayList mode = new ArrayList();
    for(int i=0;i<10;i++)
    {
    System.out.print("Enter an integer: ");
    int entered = Integer.parseInt(stdin.readLine());
    all.add(new Integer(entered));
    }









    }

    System.out.println("The median is: "+median);
    System.out.println("The mode is: "+mode);

  4. #4
    monkeyjr97 is offline Senior Member
    Join Date
    Nov 2012
    Posts
    256
    Rep Power
    3

    Default Re: i need help with a program

    What are you having trouble with exactly?

    Also you dont need to say new Integer(entered) you already define entered as an Integer.

    Also please give your ArrayLists a type, e.g.
    Java Code:
    ArrayList<Integer> ints = new ArrayList<Integer>(); etc
    If you dont specify an ArrayList type Object will be used and then you can get into all kinds of trouble like type casting every time you want to get an element from the list
    Last edited by monkeyjr97; 05-10-2013 at 04:49 AM.

  5. #5
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: i need help with a program

    [Oops, entirely wrong forum. Less gin & tonic ftw.]
    Get in the habit of using standard Java naming conventions!

Similar Threads

  1. Replies: 4
    Last Post: 11-21-2012, 02:19 PM
  2. Replies: 2
    Last Post: 04-02-2011, 01:57 PM
  3. Replies: 13
    Last Post: 03-22-2011, 07:49 AM
  4. Replies: 0
    Last Post: 04-04-2008, 03:40 PM
  5. Replies: 0
    Last Post: 10-04-2007, 10:33 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
  •