Calculate the simple interest earned or paid on an investment or loan. Simple interest is calculated only on the principal amount, or on that portion of the debt that remains unpaid. It is the easiest interest calculation method, where interest is earned or paid at a fixed rate for the entire duration of the loan or investment.
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;
}
var interest = (principal * rate * time) / 100;
var totalAmount = principal + interest;
resultDiv.innerHTML = "