Menu
Question Index
...

Write a program to calculate economy rate of a bowler. Economy rate is the number of runs given per over. Assume there are no extras like wides, no-balls etc.

Input (List) Output (double)
[12:30, 2:12, 86:60, 23:24, 54:60, 26:46, 43:28, 4:24, 75:60, 3:15, 32:43, 28:47, 0:24, 76:60] 5.27273
[34:60, 37:48, 48:60, 20:60, 15:30, 4:19, 40:60, 32:54, 45:58, 21:46, 78:60, 57:47] 4.31


import java.util.*;
class CalculateEconomyRate
{
    public static void main(String s[])
    {
        List<IninngsActivity> ininngsActivities = new ArrayList<IninngsActivity>();
        ininngsActivities.add(new IninngsActivity(45, 60));
        ininngsActivities.add(new IninngsActivity(60, 48));
        ininngsActivities.add(new IninngsActivity(23, 60));
        ininngsActivities.add(new IninngsActivity(34, 24));
        ininngsActivities.add(new IninngsActivity(12, 45));
        ininngsActivities.add(new IninngsActivity(78, 60));
        ininngsActivities.add(new IninngsActivity(34, 54));
        ininngsActivities.add(new IninngsActivity(32, 60));
        ininngsActivities.add(new IninngsActivity(12, 36));
        System.out.println("The economy rate is : " + getEconomyRate(ininngsActivities));

    }


    private static double getEconomyRate(List<IninngsActivity> ininngsActivities) {
    }

}
class IninngsActivity {

int runs;
int balls;

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

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

Doubts

Problems

Topic: Java ArrayList

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App