Results 1 to 6 of 6
  1. #1
    keimic53 is offline Member
    Join Date
    May 2014
    Posts
    3
    Rep Power
    0

    Default How to find biggest two int. numbers from four

    Hello... this is my first thread I'm posting, so sorry if I may make some mistakes.

    So, if you are a football/soccer fan, you know that in every FIFA World Cup you have 4 nations. From those 4, 2 will qualify to the Knockout stages.

    Let's say, after all the group fixtures are played, the standings are as follows :
    1. England - 6 points
    2. Spain - 4 points
    3. Brasil - 3 points
    4. Germany - 1 point

    I want to know how I can select ONLY England and Spain for the Knockout stage of the FIFA World Cup (The class I am working on).

    Thank you very much for your help.
    - Keimic53

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,559
    Rep Power
    25

    Default Re: How to find biggest two int. numbers from four

    What have you tried?
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    keimic53 is offline Member
    Join Date
    May 2014
    Posts
    3
    Rep Power
    0

    Default Re: How to find biggest two int. numbers from four

    Hello Norm, thank you for your time.

    Let's say each group's variables are:
    int t1, t2, t3, t4;
    ^ (For each team) ^

    I tried this 'Math.max' thing, which I'm still new to, to get an idea of how inexperienced I am so far.

    Example:
    int first = Math.max(t1, t2);
    int second = Math.max(t3, t4);

    But that doesn't make total sense, because if:
    (t1 = 5), (t2 = 4) , (t3 = 2), (t4 = 1)... than the qualified teams are 1 and 3, not 1 and 2, as it's supposed to be.

    Thank you again for your time
    - Keimic53

  4. #4
    keimic53 is offline Member
    Join Date
    May 2014
    Posts
    3
    Rep Power
    0

    Default Re: How to find biggest two int. numbers from four

    By the way, the points and fixtures are chosen randomly (Math.random)... although that is done.
    Sorry for not advising you earlier.

    Keep in mind also that two or more of the four teams may end up with the same points...
    Thanks.

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,559
    Rep Power
    25

    Default Re: How to find biggest two int. numbers from four

    two or more of the four teams may end up with the same points...
    What is reported if that happens?
    4 with same points
    3 with same high points
    2 with same high points
    2 with same high and 2 with same second high points
    2 with same second high points
    etc
    If you don't understand my response, don't ignore it, ask a question.

  6. #6
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,767
    Rep Power
    5

    Default Re: How to find biggest two int. numbers from four

    Quote Originally Posted by keimic53 View Post
    Example:
    int first = Math.max(t1, t2);
    int second = Math.max(t3, t4);
    There is nothing that says you can't feed the result of one max comparison, into another one.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Can StreamTokenizer find numbers followed by letters
    By kbreitsprecher in forum New To Java
    Replies: 1
    Last Post: 03-08-2012, 10:45 PM
  2. Find the Biggest Number + Smallest
    By d4v1dz in forum New To Java
    Replies: 19
    Last Post: 10-26-2011, 06:43 AM
  3. Coding to find the Harshad numbers...
    By nope in forum New To Java
    Replies: 16
    Last Post: 03-07-2011, 04:16 AM
  4. Replies: 8
    Last Post: 02-08-2011, 07:27 AM
  5. Help with my code to find MinOfAll numbers
    By May.ver.rick in forum New To Java
    Replies: 9
    Last Post: 04-20-2010, 04:46 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
  •