A Java program to create tournament pairings is to be created. The team names al
ID: 3655579 • Letter: A
Question
A Java program to create tournament pairings is to be created. The team names along with their wins should be stored in an array of objects. The teams will be entered in the order of wins; that is most wins to least wins. To create the pairings, the first team in the array (the team with the best record) is matched with the last team in the array (the team with the worst record) to form the first game of the tournament. The process is repeated, matching the team with the next best record with the team with the next worst record to form the second game. The process continues until all teams have been paired. The number of teams to be paired will always be an even power of two. For example: the input would be 4, 8, 16, 32 or 64 teams for testing. A driver class and a class to create the team object should be written. An array of objects ordered by team wins will be created as the input data is received, and then the pairings can be made as described above. The driver class should be named Tournament.Explanation / Answer
Tournament class: package tournament; import java.io.*; public class Tournament { // Set this to wherever your team file is located final static String TEAMFILE = "/home/clobberfoe/Teams.txt"; public static void main(String[] args) throws IOException { System.out.print("Enter the number of teams: "); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int numTeams = Integer.parseInt(in.readLine()); BufferedReader reader = new BufferedReader(new FileReader(TEAMFILE)); Team allTeams [] = new Team[numTeams]; for (int i=0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.