Computer Science, asked by atomelement6, 11 months ago

Tom is crazy about cricket. He was watching India vs. Australia World cup final match. Australia won the toss and elected to bat first. They finished batting with a score of X. Next, India started to bat and scored Y runs in N number of balls. As Tom is very crazy, he wants to calculate the run rate and check whether there is a probability for India to win or not. Help him calculate the run-rate and check the probability.
INPUT FORMAT & OUTPUT FORMAT:

Input consists of 4 integers. First input corresponds to the total number of balls. Second input corresponds to the total number of runs. Third input corresponds to the number of runs scored. Fourth input corresponds to the number of balls bowled. First output corresponds to the total number of overs. Second output corresponds to the total number of overs finished. Third output corresponds to the current run rate. Fourth output corresponds to total run rate.

Overs: 50 Overs finished: 7.3 Current Run rate: 10.7 Total Run rate: 7.5 Eligible to Win

SAMPLE INPUT:

300

375

78

45

SAMPLE OUTPUT:

50

7.3

10.7

7.5

Eligible to Win

Answers

Answered by mayankpathak4513
36

Answer:Required code for the above problem :

#include<iostream>

#include<iomanip>

using namespace std;

int main()

{

int a,b,x,y;

 std::cin>>a>>b>>x>>y;

 float m = a/6;

 int n = y/6;

 int p = y%6;

 float k = ((float)n + (float)p/10);

 float d = x/k;

 float f = b/m;

 std::cout<<m<<"\n";

 std::cout<<std::fixed<<std::setprecision(1)<<k<<"\n";

 std::cout<<d<<"\n"<<f<<"\n";

 if(d>f)

   std::cout<<"Eligible to Win";

 else

   std::cout<<"Not Eligible to Win";

}

Explanation:

Answered by sarahssynergy
0

Given below is the required program for predicting the winner in Python programming language.

Explanation:

  • We calculate the total number of overs and number of overs finished by dividing total number of balls and number of balls bowled by six.
  • We calculate the current run rate and total run rate by dividing total runs scored before and runs scored by the current team by six.
  • If the current run rate is more or equal to the total run rate the team is eligible to win.
  • PROGRAM:
  •      bt = int(input("Enter the number of total balls: "))
  •      rt = int(input("Enter total number of runs scored by Australia: "))
  •      ri= int(input("Enter the runs scored by India till now: "))
  •      bi= int(input("Enter the number of balls played by India till now: "))
  •      print("Total overs: ", (bt/6), "\nOvers finished: ", (bi/6), "\nCurrent run rate: ", (ri/6), "\nTotal run rate: ", (rt/6) )
  •       if ((ri/6)>=(rt/6)):  
  •               print("\n Eligible to win.")
  •       else:
  •               print("\nNot eligible to win.")

Similar questions