Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: I need help with this array problem ?

  1. #1
    Junior Member
    Join Date
    May 2014
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default I need help with this array problem ?

    My request 1.Application must admit at most 15 competitors.

    2.Data of competitor will be saved in two dimensional array , In first dimension
    save the serial number of the competitor in the second dimension should be placed and saved time of competitor in seconds for example 98sec , 120 sec etj

    i dont know where is my import
    javax.swing.*; 
       public class SkiRace {
       public void Kandidati(int a,int b) {
     
       int Candidate = 15;
       int a = JOptionPane.showInputDialog(" Put the serial number "); 
       int b = JOptionPane.showInputDialog("Put the time of Competitor ");    
     
            int [][] cand = new Candidate[Garuesit];
     
            // Pjesa e inicializimit te kandidateve:
            for(int i =0; i<cand.length; i++){
               cand[i]=new Candidate();
               cand[j]=new Candidate();
               cand[i].setName(JOptionPane.showInputDialog
                       ("Numri rendor i kandidateve "+i));
               cand[i].setName(JOptionPane.showInputDialog
                       (" Koha e garuesit "+j));
            } 
     
       }
        public static void main(String [] args) 
       { SkiRace k = new SkiRace (); 
          k.Kandidati(5,6); 
       }
       }

    Can
    Last edited by ammehmeti; May 31st, 2014 at 06:10 PM.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,105
    Thanks
    48
    Thanked 2,153 Times in 2,126 Posts

    Default Re: I need help with this array problem ?

    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE GOES HERE
    [/code]
    to get highlighting and preserve formatting.

    What specific questions do you have?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    May 2014
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I need help with this array problem ?

    i dont know how to link together " int a and int b " in array ? i tried but no succes

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,105
    Thanks
    48
    Thanked 2,153 Times in 2,126 Posts

    Default Re: I need help with this array problem ?

    how to link together " int a and int b " in array
    What do you mean by "link together"?

    The assignment says each row contains the data for a competitor and the columns contain the competitor's serial number followed by the data items. For example:
    123 44 66 77
    213 33 44 55
    For the first competitor (id = 123) the times were 44, 66, 77
    for the second (id = 213) times were 33, 44, 55
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    May 2014
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I need help with this array problem ?

    link together i mean .. i want the serial number and time of the competitor to input with JOptionPane (interactive input)

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,105
    Thanks
    48
    Thanked 2,153 Times in 2,126 Posts

    Default Re: I need help with this array problem ?

    Are you asking how to have TWO separate values returned by ONE call to the JOptionPane method?
    The standard methods only return ONE value. If you want more than one value you will have to write a custom dialog.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    May 2014
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I need help with this array problem ?

    okay all i need is to help me how to initialize a two dimensional array first dimension should save serial number ,second dimension time of 15 competitors
     int Candidate = 15;
       int a = JOptionPane.showInputDialog(" Put the serial number "); 
       int b = JOptionPane.showInputDialog("Put the time of Competitor ");    
     
            int [][] cand = new Candidate[Garuesit];
    is this right or wrong ???

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,105
    Thanks
    48
    Thanked 2,153 Times in 2,126 Posts

    Default Re: I need help with this array problem ?

    is this right or wrong ??
    What happened when you tried to compile it? The compiler is better at finding syntax errors than I am.

    how to initialize a two dimensional array first dimension should save serial number ,second dimension time of 15 competitors
    I gave a sample in post#4.

    In that sample, for the first row(index = 0)
    twoDimArr[0][0] is the serial number
    twoDimArr[0][1] is the first time
    twoDimArr[0][2] is the second time
    twoDimArr[0][3] is the third time
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Array Problem
    By hkfrenchtoast in forum What's Wrong With My Code?
    Replies: 14
    Last Post: March 11th, 2014, 09:10 PM
  2. Replies: 2
    Last Post: February 24th, 2014, 09:48 PM
  3. Replies: 2
    Last Post: May 13th, 2011, 03:08 AM
  4. Problem with array
    By mingming8888 in forum What's Wrong With My Code?
    Replies: 9
    Last Post: October 27th, 2010, 12:17 PM
  5. Java program for 2-D Array Maze
    By Peetah05 in forum Collections and Generics
    Replies: 11
    Last Post: May 8th, 2009, 04:30 AM