Absa Fixed Deposit Interest Rates in Kenya Calculator

Compound Interest Calculator

Understand how your investments can grow over time with the power of compounding. Compound interest is essentially 'interest on interest'. It means that in addition to the interest you earn on your principal amount, you also earn interest on the accumulated interest from previous periods.

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

Calculation Results

" + "Initial Investment: $" + principal.toFixed(2) + "" + "Annual Interest Rate: " + annualRate.toFixed(2) + "%" + "Investment Duration: " + time + " Years" + "Compounding Frequency: " + getCompoundingFrequencyDescription(compoundingFrequency) + "" + "Total Amount After " + time + " Years: $" + finalAmount.toFixed(2) + "" + "Total Interest Earned: $" + totalInterestEarned.toFixed(2) + ""; } function getCompoundingFrequencyDescription(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"; } } #compound-interest-calculator { font-family: sans-serif; border: 1px solid #ccc; padding: 20px; border-radius: 8px; max-width: 600px; margin: 20px auto; background-color: #f9f9f9; } #compound-interest-calculator h2 { text-align: center; color: #333; margin-bottom: 20px; } .calculator-inputs .form-group { margin-bottom: 15px; } .calculator-inputs label { display: block; margin-bottom: 5px; font-weight: bold; color: #555; } .calculator-inputs input[type="number"], .calculator-inputs select { width: calc(100% – 12px); padding: 8px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; } .calculator-inputs button { display: block; width: 100%; padding: 10px; 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; } .calculator-result { margin-top: 25px; padding: 15px; border: 1px solid #ddd; border-radius: 4px; background-color: #fff; } .calculator-result h3 { margin-top: 0; color: #333; } .calculator-result p { margin-bottom: 8px; color: #555; } .calculator-result strong { color: #333; }

Leave a Comment