Page 2 of 2 FirstFirst 12
Results 21 to 35 of 35

Thread: need help

  1. #21
    pirate is offline Member
    Join Date
    Mar 2011
    Posts
    26
    Rep Power
    0

    Default

    thank you for that but this project should be finish by tomorrow and I still can't finish it
    please i need the code......
    Last edited by pirate; 03-25-2011 at 12:17 PM.

  2. #22
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Just to let you know, if I sound rude at all it's not meant just emphasizing bad practices you don't want them to become habits.

  3. #23
    pirate is offline Member
    Join Date
    Mar 2011
    Posts
    26
    Rep Power
    0

    Default

    ..............
    Last edited by pirate; 03-25-2011 at 01:38 PM.

  4. #24
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,404
    Rep Power
    20

    Default

    If you can't finish your project, take the failing grade you deserve. Why should anyone here help you to cheat your way through?

    db

  5. #25
    pirate is offline Member
    Join Date
    Mar 2011
    Posts
    26
    Rep Power
    0

    Default

    I'm so sorry about that i'm just so confused yesterday.

  6. #26
    pirate is offline Member
    Join Date
    Mar 2011
    Posts
    26
    Rep Power
    0

    Default

    Quote Originally Posted by FlipPoker@gmail.com View Post
    If you're referring to the top 8 winners, you could loop through your candidate array and find the indexes of the two lowest vote getters. In the end, the other 8 indexes are the top 8 winners.
    how will i able to get the 2 lowest vote getters?

  7. #27
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    We went over this. It's not difficult, however; it will take some thinking and possibly reading up on how to loop properly.

    This method gets the lowest index, I'll leave it up to you to find the lowest two. Think about it, don't just guess.
    Java Code:
    int min = 0;
    for(int i = 1; i < array.length; i++){
      if(array[i] < array[min]){
        min = i;
      }
    }
    Last edited by sunde887; 03-26-2011 at 03:42 AM.

  8. #28
    pirate is offline Member
    Join Date
    Mar 2011
    Posts
    26
    Rep Power
    0

    Default

    ok..i'll try again....sorry if i cannot understand fast your directions...

  9. #29
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Do you have a textbook? Try looking through it for working with loops. If you aren't willing to use the tutorials and books to get loops explained, everything we say is gonna go over your head.

    A loop is a flow control structure which repeats some statement(or code block) as long as the condition is true. So if you use a loop and an array you can test something against every item in the array as shown in my previous post.

    Java Code:
    for(initializer; condition; increment operation){
      //statements
    }
    Last edited by sunde887; 03-26-2011 at 04:27 AM.

  10. #30
    pirate is offline Member
    Join Date
    Mar 2011
    Posts
    26
    Rep Power
    0

    Default

    do you mean i should have ten loops that will test containing the code above?

  11. #31
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    No.
    Java Code:
    for(int i = 10; i < 10; i++){
      //do something
    }
    this repeats everything in the brackets({}) 10 times.

  12. #32
    pirate is offline Member
    Join Date
    Mar 2011
    Posts
    26
    Rep Power
    0

    Default

    int min = 0;
    for(int a = 10; a < 10; a++){
    for(int i = 1; i < candidate.length; i++){
    if(candidate[i] < candidate[min]){
    min = i;

    }
    }
    }

  13. #33
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    This won't ever run since a is never less than 10.

  14. #34
    pirate is offline Member
    Join Date
    Mar 2011
    Posts
    26
    Rep Power
    0

    Default

    so a shoud be equal to 1?

  15. #35
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Perhaps, I am going to let you figure this one out. You have a lot to work on, but if you just piece together the solution from what I'm posting you won't really understand shaw going on.

    You need to read up on loops if you still don't understand exactly how they work.

Page 2 of 2 FirstFirst 12

Posting Permissions

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