function calculateBalloonLoan() {
const loanAmount = parseFloat(document.getElementById(“loanAmount”).value);
const interestRate = parseFloat(document.getElementById(“interestRate”).value) / 100;
const loanTerm = parseInt(document.getElementById(“loanTerm”).value);
const paymentFrequency = document.getElementById(“paymentFrequency”).value;
if (isNaN(loanAmount) || isNaN(interestRate) || isNaN(loanTerm) || loanAmount <= 0 || interestRate <= 0 || loanTerm <= 0) {
alert("Please enter valid values for all fields.");
return;
}
const numberOfPayments = paymentFrequency === "monthly" ? loanTerm * 12 : paymentFrequency === "quarterly" ? loanTerm * 4 : loanTerm;
const monthlyInterestRate = interestRate / 12;
const balloonPayment = loanAmount * (1 + monthlyInterestRate * numberOfPayments);
document.getElementById("balloonPaymentResult").textContent = "Final Balloon Payment: " + formatCurrency(balloonPayment);
}
function formatCurrency(amount) {
return "$" + amount.toFixed(2);
}