Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The following program read in the team stats from the input and display ranks the team based on the percentage of win. The team with

The following program read in the team stats from the input and display ranks the team based on the percentage of win. The team with the highest percentage of wins should display first.

image text in transcribedimage text in transcribed

8 import java.util.Scanner; 2 import java.util.ArrayList; 3 import java.util.Collections; 4 import java.util.Comparator.; 5 6 public class Test I public static void main(String[] args) { Scanner stdin = new Scanner(System.in); ArrayList teamStats = new ArrayList(); 10 while (stdin.hasNextLine()) { 11 // read a line and break to three pieces using space 12 String[] fields = stdin.nextLine().split(" "); 13 14 teamStats.add(new TeamStat(fields [0], Integer.parseInt(fields[1]), Integer.parseInt(fields [2]))); 15 } 16 17 // your code starts here 18 19 // your code ends here 20 for (TeamStat ts : teamStats) { 21 System.out.println(ts.getTeam() + "\t" + ts.getWin() + "\t" + ts.getLoss()); } 23 stdin.close(); 24 } 25 }| 22 2 1 class TeamStat { String team; int win; int loss; public TeamStat(String team, int win, int loss) { this.team = team; this.win = win; this.loss = loss; } public String getTeam() { return team; } public int getWin() { return win; } public int getLoss() { return loss; } 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions

Question

4. The team is trained to function without direct supervision.

Answered: 1 week ago

Question

1. What are the peculiarities of viruses ?

Answered: 1 week ago

Question

Describe the menstrual cycle in a woman.

Answered: 1 week ago