Calculate Your Interest Rate

Compound Interest Calculator

Understand how your investments grow over time with compound interest. Compound interest is calculated on the initial principal, plus all the accumulated interest from previous periods. It's often referred to as "interest on interest." The longer your money is invested, and the higher the interest rate, the more significant the impact of compounding.

Annually Semi-Annually Quarterly Monthly Daily
function calculateCompoundInterest() { var principal = parseFloat(document.getElementById("principal").value); var interestRate = parseFloat(document.getElementById("interestRate").value); var timePeriod = parseFloat(document.getElementById("timePeriod").value); var compoundingFrequency = parseInt(document.getElementById("compoundingFrequency").value); var resultDiv = document.getElementById("result"); resultDiv.innerHTML = ""; // Clear previous results if (isNaN(principal) || isNaN(interestRate) || isNaN(timePeriod) || isNaN(compoundingFrequency)) { resultDiv.innerHTML = "Please enter valid numbers for all fields."; return; } if (principal <= 0 || interestRate < 0 || timePeriod <= 0 || compoundingFrequency <= 0) { resultDiv.innerHTML = "Please enter positive values for principal, time period, and compounding frequency, and a non-negative interest rate."; return; } var ratePerPeriod = interestRate / 100 / compoundingFrequency; var numberOfPeriods = timePeriod * compoundingFrequency; var futureValue = principal * Math.pow((1 + ratePerPeriod), numberOfPeriods); var totalInterestEarned = futureValue – principal; resultDiv.innerHTML = "

Results

" + "Initial Investment: $" + principal.toFixed(2) + "" + "Annual Interest Rate: " + interestRate.toFixed(2) + "%" + "Time Period: " + timePeriod + " years" + "Compounding Frequency: " + getFrequencyText(compoundingFrequency) + "" + "Future Value: $" + futureValue.toFixed(2) + "" + "Total Interest Earned: $" + totalInterestEarned.toFixed(2) + ""; } function getFrequencyText(frequency) { switch(frequency) { case 1: return "Annually"; case 2: return "Semi-Annually"; case 4: return "Quarterly"; case 12: return "Monthly"; case 365: return "Daily"; default: return "Unknown"; } } .calculator-container { font-family: sans-serif; border: 1px solid #ccc; padding: 20px; border-radius: 8px; max-width: 600px; margin: 20px auto; background-color: #f9f9f9; } .calculator-container h2 { text-align: center; color: #333; margin-bottom: 20px; } .calculator-inputs { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 20px; } .input-group { display: flex; flex-direction: column; } .input-group label { margin-bottom: 5px; font-weight: bold; color: #555; } .input-group input, .input-group select { padding: 10px; border: 1px solid #ddd; border-radius: 4px; font-size: 1rem; } .calculator-container button { grid-column: 1 / -1; padding: 12px 20px; background-color: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 1.1rem; transition: background-color 0.3s ease; } .calculator-container button:hover { background-color: #0056b3; } .calculator-result { margin-top: 20px; padding: 15px; background-color: #e9ecef; border: 1px solid #dee2e6; border-radius: 4px; } .calculator-result h3 { margin-top: 0; color: #333; } .calculator-result p { margin-bottom: 8px; color: #444; } .calculator-result strong { color: #000; }

Leave a Comment