Results 1 to 20 of 20
Like Tree1Likes
  • 1 Post By Junky

Thread: Find the Biggest Number + Smallest

  1. #1
    d4v1dz is offline Member
    Join Date
    Oct 2011
    Posts
    5
    Rep Power
    0

    Default Find the Biggest Number + Smallest

    Not coming back here for help....
    Last edited by d4v1dz; 10-25-2011 at 11:30 PM.

  2. #2
    joeyvitoro is offline Member
    Join Date
    Oct 2011
    Posts
    90
    Rep Power
    0

    Default Re: Find the Biggest Number + Smallest

    Well, you will need to have all of those scores available to you at the end of your loop to determine the smallest and biggest. Do you know how to store several numbers that are related?

  3. #3
    d4v1dz is offline Member
    Join Date
    Oct 2011
    Posts
    5
    Rep Power
    0

    Default Re: Find the Biggest Number + Smallest

    arent the stored numbers in "total"?

  4. #4
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default Re: Find the Biggest Number + Smallest

    Quote Originally Posted by joeyvitoro View Post
    Well, you will need to have all of those scores available to you at the end of your loop to determine the smallest and biggest.
    Not so. All you need is 3 variables: current score, highest score and lowest score. Each time a new value is read into current score you compare it to highest/lowest to see if it is the new highest/lowest score.

  5. #5
    d4v1dz is offline Member
    Join Date
    Oct 2011
    Posts
    5
    Rep Power
    0

    Default Re: Find the Biggest Number + Smallest

    Quote Originally Posted by Junky View Post
    Not so. All you need is 3 variables: current score, highest score and lowest score. Each time a new value is read into current score you compare it to highest/lowest to see if it is the new highest/lowest score.
    yes but how would I do that?

  6. #6
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default Re: Find the Biggest Number + Smallest

    Do you know how to declare variables?
    Do you know how to assign values to variables?
    Do you know how to use if statements?

    If you answered yes to all three questions then you know how to do it.

  7. #7
    joeyvitoro is offline Member
    Join Date
    Oct 2011
    Posts
    90
    Rep Power
    0

    Default Re: Find the Biggest Number + Smallest

    Although true Junky, I imagine an introduction to the Math library would be beneficial in a beginners programming class.

  8. #8
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default Re: Find the Biggest Number + Smallest

    What the heck has a Math Library got to do with it?
    Fubarable likes this.

  9. #9
    d4v1dz is offline Member
    Join Date
    Oct 2011
    Posts
    5
    Rep Power
    0

    Default Re: Find the Biggest Number + Smallest

    Thats like no help. If I knew how to do it, I wouldnt be asking for help. I need someone to explain it

  10. #10
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: Find the Biggest Number + Smallest

    You'll want to declare two variables before the while loop, a highest and a lowest variable, and then inside of the loop check to see if any entered values are higher than the highest or lower than the lowest. You can initialize the highest value with the lowest possible int available, Integer.MAX_VALUE and the high variable with Integer.MIN_VALUE.

  11. #11
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default Re: Find the Biggest Number + Smallest

    Well give up then!

    I gave you all the help you need. If you do not know how to do any of those things I mentioned then you either need to do some serious revision or drop the course.

  12. #12
    joeyvitoro is offline Member
    Join Date
    Oct 2011
    Posts
    90
    Rep Power
    0

    Default Re: Find the Biggest Number + Smallest

    Well I was going to suggest using min and max...

    d4, what is your min and max before you start? How about after the first loop iteration? The second? etc

  13. #13
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: Find the Biggest Number + Smallest

    Quote Originally Posted by d4v1dz View Post
    Thats like no help. If I knew how to do it, I wouldnt be asking for help. I need someone to explain it
    It's usually best to at least give a stab at it, try to solve this little issue and show us your attempt before completely giving in and throwing in the towel. Also, it's not a good a idea to say "that's like no help". Even if you don't see his point, he did take time out to consider your problem and try to help you, so being rude to him will only make him and others not want to help you in the future.

  14. #14
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: Find the Biggest Number + Smallest

    Quote Originally Posted by joeyvitoro View Post
    Well I was going to suggest using min and max...

    d4, what is your min and max before you start? How about after the first loop iteration? The second? etc
    Better to avoid the Math library at this point. A simple boolean expression is good enough for his needs, I think.

  15. #15
    d4v1dz is offline Member
    Join Date
    Oct 2011
    Posts
    5
    Rep Power
    0

    Default Re: Find the Biggest Number + Smallest

    Quote Originally Posted by Junky View Post
    Well give up then!

    I gave you all the help you need. If you do not know how to do any of those things I mentioned then you either need to do some serious revision or drop the course.
    OMFG. Its a High school class, 2nd week of doing java. This community blows with its members... Your retarded. Im out of here, rather ask help on a different forum.

    PS: Thanks Fubarable for actually explaining it...

  16. #16
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default Re: Find the Biggest Number + Smallest

    Open wide here comes the choo-choo train.
    Java Code:
    int max = Integer.MIN_VALUE;
    int min = Integer.MAX_VALUE;
    Any value entered by user is mostly assured to be less than min and greater than max. Then you can do:
    Java Code:
    if current value is less than min
        min = current value
    if current value is greater than max
        max = current value

  17. #17
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default Re: Find the Biggest Number + Smallest

    Well I was trying to help by getting you to think for yourself but all you did was throw your arms up in the air and whine "I don't know how to do it" without even trying. My above post just about gives you the solution. Are you happy now?

  18. #18
    joeyvitoro is offline Member
    Join Date
    Oct 2011
    Posts
    90
    Rep Power
    0

    Default Re: Find the Biggest Number + Smallest

    D4, sorry you had a bad experience man, but these forums are mostly good. Some people here simply find it easier to be rude than explain why they aren't going to give you the answer.

  19. #19
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default Re: Find the Biggest Number + Smallest

    My posting style can be rough to those who appear not to try and solve the problem themselves and just expect to be given the answer. This is the attitude I was getting from the OP.

  20. #20
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,000
    Blog Entries
    7
    Rep Power
    20

    Default Re: Find the Biggest Number + Smallest

    Well, the OP is gone (according to the edited first post) so I'll close this thread. The original problem statement is gone, so all replies have become (sort of) useless.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Help me with my biggest project
    By ron2794 in forum New To Java
    Replies: 0
    Last Post: 06-10-2011, 05:55 PM
  2. smallest number java program
    By elmo in forum New To Java
    Replies: 9
    Last Post: 11-18-2010, 09:29 PM
  3. Find max number in 2D array?
    By spatel14 in forum New To Java
    Replies: 3
    Last Post: 06-30-2010, 04:27 PM
  4. html, biggest nightmare ever
    By dinosoep in forum New To Java
    Replies: 9
    Last Post: 12-03-2009, 08:50 AM
  5. Find nth root of a number
    By perito in forum New To Java
    Replies: 1
    Last Post: 03-03-2008, 06:51 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
  •