info@meritcampus.com    +91-85006-22255
...

Write a program to calculate the points gained and the net run rate of each team. 2 points for every win, 1 point for tie. Net Run Rate is nothing but the difference of teams run rates. While calculating the run rate, assume that the number of overs is 50, even if they did not bat till the end.

Input (List) Output (List)
[India:200:50 - England:202:40, Pakistan:254:50 - India:260:41, Sri Lanka:222:50 - England:222:50, India:245:50 - Sri Lanka:180:31, England:210:50 - Pakistan:211:48, Pakistan:199:50 - Sri Lanka:200:40] [[India, 3, 2, 1, 0, 4, 2.10], [Sri Lanka, 3, 1, 1, 1, 3, 1.04], [England, 3, 1, 1, 1, 3, 0.68], [Pakistan, 3, 1, 2, 0, 2, 0.28]]
[India:200:50 - England:202:40, Pakistan:254:50 - India:260:41, England:312:50 - Australia:313:49, Sri Lanka:222:50 - England:222:50, Australia:324:50 - India:325:41, India:245:50 - Sri Lanka:180:31, Sri Lanka:324:50 - Australia:298:50, England:210:50 - Pakistan:211:48, Pakistan:199:50 - Sri Lanka:200:40, Australia:354:50 - Pakistan:300:50] [[India, 4, 3, 1, 0, 6, 2.60], [Sri Lanka, 4, 2, 1, 1, 5, 2.52], [Australia, 4, 2, 2, 0, 4, 1.78], [England, 4, 1, 2, 1, 3, 0.92], [Pakistan, 4, 1, 3, 0, 2, -0.72]]

``` class CalculateTeamPoints {    public static void main(String s[])    {        List matchActivities = new ArrayList();        matchActivities.add(new MatchActivity(new TeamActivity("India", 300, 50), new TeamActivity("Pakistan", 220, 50)));        matchActivities.add(new MatchActivity(new TeamActivity("Pakistan", 254, 50), new TeamActivity("Sri Lanka", 260, 49)));        matchActivities.add(new MatchActivity(new TeamActivity("Sri Lanka", 220, 50), new TeamActivity("India", 222, 33)));        System.out.println(getTeamPositions(matchActivities));    } private static List<TeamPoints> getTeamPositions(List<MatchActivity> matchActivities) { //Write code here to calculate the points gained and the net run rate of each team } //If required, write any additional methods here } class MatchActivity { TeamActivity team1; TeamActivity team2; public MatchActivity(TeamActivity team1, TeamActivity team2) { super(); this.team1 = team1; this.team2 = team2; } } class TeamActivity { String team; int score; int oversPlayed; public TeamActivity(String team, int score, int oversPlayed) { this.team = team; this.score = score; this.oversPlayed = oversPlayed; } } class TeamPoints { String team; int matches; int won; int loss; int tie; int points; double netRunRate; public TeamPoints(String team, int matches, int won, int loss, int tie, int points, double netRunRate) { super(); this.team = team; this.matches = matches; this.won = won; this.loss = loss; this.tie = tie; this.points = points; this.netRunRate = netRunRate; } @Override public String toString() { return "[" + team + ", " + matches + ", " + won + ", " + loss + ", " + tie + ", " + points + ", " + new DecimalFormat("##0.00").format(netRunRate) + "]"; } } ```
0
Wrong
Score more than 2 points