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

Write a program to calculate the run rate and the score at the end of each over.

Input (List) Output (List)
[2:false, 1:false, 0:false, 0:false, 1:false, 4:false, 0:false, 0:false, 1:false, 3:false, 4:false, 1:false, 0:true, 1:false, 0:true, 2:false, 4:false, 6:false] [8(1) RR:8.0, 17(2) RR:8.5, 30(3) RR:10.0]
[0:false, 0:false, 4:false, 4:false, 1:false, 4:false, 0:true, 0:false, 0:true, 6:false, 4:false, 6:false, 0:true, 1:false, 0:true, 6:false, 4:false, 6:false] [13(1) RR:13.0, 29(2) RR:14.5, 46(3) RR:15.333333333333334]
[0:false, 0:false, 0:false, 0:true, 6:false, 6:false, 0:true, 4:false, 4:false, 4:false, 4:false, 0:true] [12(1) RR:12.0, 28(2) RR:14.0]

class GetRunRateOfEachOver

{    public static void main(String s[])
{
List ballActivities = new ArrayList();
List overDetailsList = getOverDetails(ballActivities);
System.out.println("The run rates at the end of each over are : ");
System.out.println(overDetailsList);

}

private static List<OverDetails> getOverDetails(List<BallActivity> ballActivities) {
//Write code here to calculate the run rate and the score at the end of each over.
}
}
class BallActivity {

int runs;
boolean wicket;

public BallActivity(int runs, boolean wicket) {
this.runs = runs;
this.wicket = wicket;
}

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

class OverDetails {

int over;
double runRate;
int totalScore;

public OverDetails(int over, double runRate, int totalScore) {
this.over = over;
this.runRate = runRate;
this.totalScore = totalScore;
}

@Override
public boolean equals(Object obj) {
OverDetails other = (OverDetails) obj;
return over == other.over && runRate == other.runRate && totalScore == other.totalScore;
}

@Override
public String toString() {
return totalScore + "(" + over + ")" + " RR:" + runRate;
}
}
0
Wrong
Score more than 2 points