<pre> for (int i = 0; i < teamNo; i++) { System.out.println("Enter Name of team " + (i + 1)); teamName[i] = scan.next(); } for (int a = 0; a < eventNo; a++) { for (int i = 0; i < teamNo; i++) { System.out.println("Enter rank of the team " + (teamName[i]) + " on the event " + (a + 1)); teamRank = scan.nextInt(); int tRank = 0; // scoring system for the teams switch (teamRank) { case 3: tRank = 5; break; case 2: tRank = 10; break; case 1: tRank = 20; break; } if (teamRank == 0 || teamRank >= 4) { System.out.println("The team will not be awarded points"); } else { teamScore[i] += tRank; System.out.println(tRank + " points is granted for this event\n"); } if (scan.hasNextLine()) { scan.nextLine(); } } int topTScore = 0; // this will be used to find the highest value score int topteam = -1; // and this will be the index of the team for (int i = 0; i < teamNo; i++) { if (teamScore[i] > topTScore) { topTScore = teamScore[i]; // the highest score (up to now) topteam = i; // save the team number for the one with the highest score } } System.out.println(teamName[topteam] + " is the winner, with a score of " + topTScore+"\n"); System.out.println("Enter the team names who you wish to remove after event 1"); int removeIndex = 1; for (int i = removeIndex; i < teamName.length - 1; i++) { teamName[i] = teamName[i + 1]; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)