Ear Rate Calculator

EAR Rate Calculator

The EAR (Effective Annual Rate) is the actual annual rate of interest earned on an investment or paid on a loan, taking into account the effect of compounding. It is a more accurate measure than the nominal annual rate when interest is compounded more than once a year.

Result:

function calculateEAR() { var nominalRate = parseFloat(document.getElementById("nominalRate").value); var compoundingPeriods = parseInt(document.getElementById("compoundingPeriods").value); var earResultElement = document.getElementById("earResult"); if (isNaN(nominalRate) || isNaN(compoundingPeriods) || compoundingPeriods <= 0) { earResultElement.textContent = "Please enter valid numbers for both fields, with compounding periods greater than zero."; return; } // Formula for EAR: EAR = (1 + (nominalRate / 100 / compoundingPeriods))^compoundingPeriods – 1 var periodicRate = nominalRate / 100 / compoundingPeriods; var ear = Math.pow((1 + periodicRate), compoundingPeriods) – 1; // Display the result as a percentage earResultElement.textContent = (ear * 100).toFixed(4) + "%"; } .calculator-container { font-family: sans-serif; border: 1px solid #ccc; padding: 20px; border-radius: 8px; max-width: 400px; margin: 20px auto; background-color: #f9f9f9; } .calculator-container h2 { text-align: center; margin-bottom: 15px; color: #333; } .calculator-container p { margin-bottom: 20px; line-height: 1.5; color: #555; } .input-section { margin-bottom: 15px; } .input-section label { display: block; margin-bottom: 5px; font-weight: bold; color: #444; } .input-section input[type="number"] { width: calc(100% – 22px); padding: 10px; margin-bottom: 10px; border: 1px solid #ddd; border-radius: 4px; box-sizing: border-box; } .calculator-container button { width: 100%; padding: 10px 15px; background-color: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; transition: background-color 0.3s ease; } .calculator-container button:hover { background-color: #0056b3; } .result-section { margin-top: 20px; padding-top: 15px; border-top: 1px solid #eee; } .result-section h3 { margin-bottom: 10px; color: #333; } #earResult { font-size: 1.2em; font-weight: bold; color: #28a745; }

Leave a Comment