Results 1 to 3 of 3
  1. #1
    dl21 is offline Member
    Join Date
    Apr 2008
    Posts
    3
    Rep Power
    0

    Default A problem in practicing the array

    The question is :ask the array size
    allocate space call method1
    ask user for a four digit number
    Method 1: filled up the array with four digit random number
    Method 2: check if the number is in the array
    call method 2 display if the number user input is in the array and at which array


    My job stops at:
    import javax.swing.JOptionPane;

    public class inClassArray

    {
    public static void main(String[] args)

    {
    double[] array;

    String arraySizeString = JOptionPane.showInputDialog(null,"Please enter the size of array:");

    int arraySize = Integer.parseInt(arraySizeString);

    String num1String = JOptionPane.showInputDialog(null,"please enter a four-digit number:");

    double num1 = Double.parseDouble(num1String);





    for(int i = 0; i < arraySize; i++)
    {
    String stringRandomNum= JOptionPane.showInputDialog(null,"Please input the four-digit number to allocate in the array" + (i+1));

    array[i] = Double.parseDouble(stringRandomNum);

    }
    public static double sameNum(double[] array)
    {
    for ( int i = 0; i < arraySize; i ++ );
    if
    num1 = array[i];
    return
    }



    }
    }

    can anyone help me?really appreciate!!!

  2. #2
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    Maybe your question is
    can anyone help me?
    What is the problem on your code?
    freedom exists in the world of ideas

  3. #3
    SCS17 is offline Member
    Join Date
    Nov 2007
    Posts
    20
    Rep Power
    0

    Default

    Your code is messy.. for start you should return something from your last method.

Similar Threads

  1. array problem
    By oceansdepth in forum New To Java
    Replies: 3
    Last Post: 04-05-2008, 03:25 AM
  2. Array problem.. help needed please!
    By SCS17 in forum New To Java
    Replies: 3
    Last Post: 03-06-2008, 11:30 PM
  3. Array List Problem
    By khamuruddeen in forum New To Java
    Replies: 1
    Last Post: 12-22-2007, 09:10 AM
  4. array problem
    By wats in forum New To Java
    Replies: 1
    Last Post: 12-12-2007, 08:08 AM
  5. array problem
    By Albert in forum Advanced Java
    Replies: 2
    Last Post: 07-01-2007, 02:13 AM

Posting Permissions

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