Cibc Car Loan Calculator

CIBC Car Loan Calculator

Monthly Payment: $0.00

Total Payment: $0.00

Total Interest: $0.00

function calculateCarLoan() { const loanAmount = parseFloat(document.getElementById(“loanAmount”).value); const loanTerm = parseFloat(document.getElementById(“loanTerm”).value); const interestRate = parseFloat(document.getElementById(“interestRate”).value); const downPayment = parseFloat(document.getElementById(“downPayment”).value); if (isNaN(loanAmount) || isNaN(loanTerm) || isNaN(interestRate) || isNaN(downPayment)) { alert(“Please fill in all fields with valid values.”); return; } const principal = loanAmount – downPayment; const monthlyRate = (interestRate / 100) / 12; const numberOfPayments = loanTerm * 12; const monthlyPayment = (principal * monthlyRate) / (1 – Math.pow(1 + monthlyRate, -numberOfPayments)); const totalPayment = monthlyPayment * numberOfPayments; const totalInterest = totalPayment – principal; document.getElementById(“monthlyPayment”).textContent = “Monthly Payment: $” + monthlyPayment.toFixed(2); document.getElementById(“totalPayment”).textContent = “Total Payment: $” + totalPayment.toFixed(2); document.getElementById(“totalInterest”).textContent = “Total Interest: $” + totalInterest.toFixed(2); }

Leave a Reply

Your email address will not be published. Required fields are marked *