Car Loan Calculator with Balloon Australia
function calculateCarLoan() {
const loanAmount = parseFloat(document.getElementById(‘loanAmount’).value);
const interestRate = parseFloat(document.getElementById(‘interestRate’).value) / 100 / 12;
const loanTerm = parseInt(document.getElementById(‘loanTerm’).value) * 12;
const balloonPayment = parseFloat(document.getElementById(‘balloonPayment’).value);
if (isNaN(loanAmount) || isNaN(interestRate) || isNaN(loanTerm) || isNaN(balloonPayment)) {
alert(“Please fill in all fields correctly.”);
return;
}
const monthlyPayment = (loanAmount * interestRate) / (1 – Math.pow(1 + interestRate, -loanTerm));
const totalLoanRepayment = (monthlyPayment * loanTerm) + balloonPayment;
document.getElementById(‘monthlyPayment’).value = monthlyPayment.toFixed(2);
document.getElementById(‘totalLoanRepayment’).value = totalLoanRepayment.toFixed(2);
}
function resetCalculator() {
document.getElementById(‘carLoanCalculatorForm’).reset();
}