Results 1 to 2 of 2

Thread: Major number

  1. #1
    lobodelbosque is offline Member
    Join Date
    Nov 2009
    Posts
    12
    Rep Power
    0

    Default Major number

    Hi:

    I have done a class that select the major number from an array of numbers. I'd like to know if its good.

    Thanks.

    public class MajorNumber {

    /**
    * @param args
    */
    public static void main(String[] args) {
    // TODO Auto-generated method stub

    int numbers[]={5,7,8,8,8,8,19,9,9,10,1};
    int i=0;
    int major=0;
    int j=0;int k=1;


    for(i=0;i<numeros.length -1;i++)
    {


    if(numeros[j]>numeros[k])
    {
    mayor=numeros[j];
    k++;
    }
    else
    {
    mayor=numeros[k];
    j=k;
    k++;

    }


    }

  2. #2
    collin389 is offline Senior Member
    Join Date
    Nov 2009
    Posts
    235
    Rep Power
    6

    Default

    Yeah it will work if you change all "mayor" to "major" and "numeros" to "numbers" or vis a versa

Similar Threads

  1. Replies: 1
    Last Post: 08-07-2009, 01:14 PM
  2. Replies: 1
    Last Post: 07-16-2009, 03:15 PM
  3. Replies: 1
    Last Post: 11-03-2008, 03:38 PM
  4. Software Engineer...Computer Science Major
    By giganews35 in forum Introductions
    Replies: 2
    Last Post: 09-14-2008, 10:19 AM
  5. line number
    By kazitula in forum New To Java
    Replies: 3
    Last Post: 11-21-2007, 11:27 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
  •