Calculate Uhaul Cost

Compound Interest Calculator

Calculate the future value of your investments.

Total Future Balance:
$0.00
Interest Earned: $0.00
function calculateInvestment() { var p = parseFloat(document.getElementById('principal').value); var r = parseFloat(document.getElementById('rate').value) / 100; var t = parseFloat(document.getElementById('years').value); if (isNaN(p) || isNaN(r) || isNaN(t)) { alert('Please enter valid numbers'); return; } var amount = p * Math.pow((1 + r), t); var interest = amount – p; document.getElementById('total-value').innerText = '$' + amount.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}); document.getElementById('total-interest').innerText = 'Interest Earned: $' + interest.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}); document.getElementById('result-box').style.display = 'block'; }

Leave a Comment