Calculate Interest Rates on Savings

Simple Interest Calculator

This calculator helps you determine the simple interest earned on an investment or the simple interest paid on a loan. Simple interest is calculated only on the principal amount, or on that portion of the loan amount that is still outstanding.

function calculateSimpleInterest() { var principal = parseFloat(document.getElementById("principal").value); var rate = parseFloat(document.getElementById("rate").value); var time = parseFloat(document.getElementById("time").value); var resultDiv = document.getElementById("result"); if (isNaN(principal) || isNaN(rate) || isNaN(time) || principal < 0 || rate < 0 || time < 0) { resultDiv.innerHTML = "Please enter valid positive numbers for all fields."; return; } // Formula for Simple Interest: SI = (P * R * T) / 100 var interest = (principal * rate * time) / 100; var totalAmount = principal + interest; resultDiv.innerHTML = "

Results:

" + "Simple Interest Earned/Paid: $" + interest.toFixed(2) + "" + "Total Amount (Principal + Interest): $" + totalAmount.toFixed(2) + ""; } .calculator-container { font-family: sans-serif; border: 1px solid #ccc; padding: 20px; border-radius: 5px; max-width: 500px; margin: 20px auto; background-color: #f9f9f9; } .calculator-container h2 { text-align: center; margin-bottom: 20px; color: #333; } .calculator-form { display: flex; flex-direction: column; gap: 15px; } .form-group { display: flex; flex-direction: column; } .form-group label { margin-bottom: 5px; font-weight: bold; color: #555; } .form-group input { padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 1rem; } .calculator-container button { padding: 12px 20px; background-color: #007bff; color: white; border: none; border-radius: 4px; font-size: 1.1rem; cursor: pointer; 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 #ced4da; border-radius: 4px; font-size: 1rem; color: #333; } .calculator-result h3 { margin-top: 0; color: #0056b3; }

Leave a Comment