Cricket Run Rate Calculation

Cricket Run Rate Calculator

This calculator helps you determine the current run rate and required run rate in a cricket match. Understanding run rates is crucial for assessing a team's progress towards a target or for analyzing their scoring speed during an innings.

Current Match Stats





Target Match Stats (for Required Run Rate)





function calculateRunRate() { var runsScored = parseFloat(document.getElementById("runsScored").value); var oversBowled = parseFloat(document.getElementById("oversBowled").value); var targetRuns = parseFloat(document.getElementById("targetRuns").value); var oversRemaining = parseFloat(document.getElementById("oversRemaining").value); var resultDiv = document.getElementById("runRateResult"); resultDiv.innerHTML = ""; // Clear previous results if (isNaN(runsScored) || isNaN(oversBowled) || isNaN(targetRuns) || isNaN(oversRemaining)) { resultDiv.innerHTML = "Please enter valid numbers for all fields."; return; } // Calculate Current Run Rate var currentRunRate = 0; if (oversBowled > 0) { currentRunRate = runsScored / oversBowled; } else if (runsScored > 0) { currentRunRate = runsScored; // If 0 overs bowled but runs scored, it implies a very high rate conceptually } // Calculate Required Run Rate var runsNeeded = targetRuns – runsScored; var requiredRunRate = 0; if (oversRemaining > 0) { requiredRunRate = runsNeeded / oversRemaining; } else if (runsNeeded > 0) { requiredRunRate = Infinity; // If no overs remaining and runs are still needed } else { requiredRunRate = 0; // If target met or exceeded with no overs remaining } // Ensure no negative required run rate if target is already met if (requiredRunRate < 0) { requiredRunRate = 0; } var output = "

Results:

"; output += "Current Run Rate: " + currentRunRate.toFixed(2) + " runs per over"; output += "Runs Needed: " + runsNeeded + ""; output += "Required Run Rate: " + (requiredRunRate === Infinity ? "N/A (Target Met/Exceeded)" : requiredRunRate.toFixed(2) + " runs per over") + ""; resultDiv.innerHTML = output; } #cricketRunRateCalculator { font-family: sans-serif; border: 1px solid #ccc; padding: 20px; border-radius: 8px; max-width: 500px; margin: 20px auto; background-color: #f9f9f9; } #cricketRunRateCalculator h2, #cricketRunRateCalculator h3 { text-align: center; color: #333; } .calculator-inputs { margin-top: 15px; text-align: center; } .calculator-inputs label { display: inline-block; width: 150px; margin-right: 10px; text-align: right; font-weight: bold; } .calculator-inputs input[type="number"] { padding: 8px; margin-bottom: 10px; border: 1px solid #ddd; border-radius: 4px; width: 100px; } .calculator-inputs button { padding: 10px 20px; background-color: #4CAF50; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; margin-top: 15px; } .calculator-inputs button:hover { background-color: #45a049; } #runRateResult { margin-top: 20px; padding: 15px; border-top: 1px solid #eee; text-align: center; background-color: #fff; border-radius: 4px; }

Leave a Comment