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 6 of 6

Thread: For loops to figure a table of round robin, 8 & 16 teams

  1. #1
    Member
    Join Date
    Dec 2013
    Location
    Honolulu
    Posts
    83
    Thanks
    1
    Thanked 4 Times in 2 Posts

    Default For loops to figure a table of round robin, 8 & 16 teams

    Hello everyone. I am trying to figure out a table, that would show the match ups of a round robin tournament, chess, basketball, or baseball. It is a team of 8 or 16 teams in the tournament. Each team plays all participants at least once. Single round robin matches. I will start with the 8 teams. There will be (n-1) rounds, and n + 1 = 8 games per team. In all 7 rounds. This table must show each player 1 to 8 playing an opponent at least once. So I counted 8 Columns, and 7 rows and with no subtitles. So here is what what I came up with the 8 teams round robin tournament.
    import (something, i'll figure it out later
     
    //the files or class imported
     
    public class TeamsTable  {
       String n;
     
       public static void main(String[ ] args)  {
       for(int I = 0; I > = 8; I ++) {
     
     
      }
     
    }
     
     
    } // not finish, pardon the wait.

    Studying codes. Already have the table made out for the 8 team tournament on paper. I just want to show the format table on a JApplet.

    Thanks for your patience. I'll be right back. Working on the program on the top of my head and researching the graph or tables.
    For example, team 1, would play
    Teams 2 to team 7. Team 2 would play team 1, & team 3 to 8. Team 3 would play team 1 & 2, & team 4 to 8. This would continue for 7 rounds of play for each team 1 through 8. Since I already have the numbers of pairs for each team, I just need a chart graph to put those numbers in. So for now, let us assume the graph has "****" to fill in as numbers. I just want to draw the chart graph. I can put in the "dummy" variables" "****" now. I just want to see how the chart will look. No need yet to put the numbers in here,.the numbers is not the issue. Making the 8 x 7 chart is my only concern. Filling in those numbers would be.easy.

    I am working in the dark. So the details are off my head. The codes are a duzzy. After working on the round robin charts.by pen for both 8 teams and 16 teams, at present java programming became blank to me, as I am typing this in the dark.

    Thank you for understanding or seeing the conceptual idea, even though getting those numbers now, and on my mobile phone, would be counter productive. So, thanks again if you understood the problem.

  2. #2
    Member
    Join Date
    Dec 2013
    Location
    Honolulu
    Posts
    83
    Thanks
    1
    Thanked 4 Times in 2 Posts

    Default Re: For loops to figure a table of round robin, 8 & 16 teams

    8 Team

    As follows;
    Team 1 plays t2 to t8.
    Team 2 plays t1 & t3 to t8.
    Team 3 plays t1,t2, & t4 to t8.
    Team 4 plays t1-t3 & t5-t8
    Team 5 plays t1-t4 & t6-t8
    Team 6 plays t1-t5 & t7-t8
    Team 7 plays t1-t6 & t8
    Team 8 plays t1-t7

    Round robin play

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: For loops to figure a table of round robin, 8 & 16 teams

    Do you have any specific java programming questions?
    If you don't understand my answer, don't ignore it, ask a question.

  4. #4
    Member
    Join Date
    Dec 2013
    Location
    Honolulu
    Posts
    83
    Thanks
    1
    Thanked 4 Times in 2 Posts

    Default Re: For loops to figure a table of round robin, 8 & 16 teams

    Yes.

    public static void main(String args[ ]) {
      for(int i=0;i<=9;i++) {
         if(i==1)
         {
          continue;
        }
        System.out.println(i + " ");
       }
    }

    In the public method, the output is,
    O 2 3 4 5 6 7 8 9

    How can I space this out to get equal columns and spacing?

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: For loops to figure a table of round robin, 8 & 16 teams

    How can I space this out
    Use the printf method with a format String that adds the desired spaces to the output.
    If you don't understand my answer, don't ignore it, ask a question.

  6. #6
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default Re: For loops to figure a table of round robin, 8 & 16 teams

    Quote Originally Posted by planetHollywood View Post
    8 Team

    As follows;
    Team 1 plays t2 to t8.
    Team 2 plays t1 & t3 to t8.
    Team 3 plays t1,t2, & t4 to t8.
    Team 4 plays t1-t3 & t5-t8
    Team 5 plays t1-t4 & t6-t8
    Team 6 plays t1-t5 & t7-t8
    Team 7 plays t1-t6 & t8
    Team 8 plays t1-t7

    Round robin play
    It's quite possible I'm missing something, but "Team 1 plays t2", then later "Team 3 plays t1...". Isn't team 1 overbooked? Surely what matters is who plays whom in what round.

    Coming up with a scheme which specifies which team plays against which in each round, and which ensures each team plays against all their opponents exactly once (for any number of teams) is a classic problem, but well worth thinking about before looking up "teh answer".

    ---

    For formatting the output the tutorial at www.javawithus.com looks decent.

Similar Threads

  1. [SOLVED] How to make Math.round() round to the nearest .1?
    By bdennin in forum What's Wrong With My Code?
    Replies: 4
    Last Post: February 2nd, 2013, 07:23 PM
  2. New to Java Can not figure out how to create a table with my codes outputs!
    By shoppa028 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 12th, 2011, 09:21 AM