Menu
Question Index
...

Write a program to calculate the strike rate of batsman. The strike rate is number of runs obtained per balls faced.

Input (List) Output (double)
[10:30, 24:12, 111:84, 155:184, 54:109, 48:122, 99:121, 98:58, 134:112, 78:151, 94:56, 82:47, 0:15, 12:25] 88.72114
[121:90, 34:45, 44:92, 123:155, 32:45, 4:12, 2:3, 65:23, 67:32, 0:12, 13:6, 0:6] 96.92898


import java.util.*;
class GetBatsmanStrikeRate
{
    public static void main(String s[])
    {
        List<MatchIninngsActivity> ininngsActivity = new ArrayList<MatchIninngsActivity>();
        ininngsActivity.add(new MatchIninngsActivity(120, 121));
        ininngsActivity.add(new MatchIninngsActivity(100, 112));
        ininngsActivity.add(new MatchIninngsActivity(0, 12));
        ininngsActivity.add(new MatchIninngsActivity(12, 25));
        ininngsActivity.add(new MatchIninngsActivity(112, 72));
        ininngsActivity.add(new MatchIninngsActivity(54, 23));
        ininngsActivity.add(new MatchIninngsActivity(0, 12));
        ininngsActivity.add(new MatchIninngsActivity(56, 111));
        ininngsActivity.add(new MatchIninngsActivity(23, 58));
        System.out.println("The Strike rate is : " + getStrikeRate(ininngsActivity));

    }


    private static double getStrikeRate(List<MatchIninngsActivity> ininngsActivities) {
    }

}
class MatchIninngsActivity {

int runs;
int balls;

public MatchIninngsActivity(int runs, int balls) {
this.runs = runs;
this.balls = balls;
}

@Override
public String toString() {
return runs + ":" + balls;
}
}

Doubts

Problems

Topic: Collection Framework In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App