simulador
0.50.6
0.080.09
5101520
function calcularHipoteca() { const costoCasa = parseFloat(document.getElementById(‘costoCasa’).value); const enganche = parseFloat(document.getElementById(‘enganche’).value); const avaluo = parseFloat(document.getElementById(‘avaluo’).value); const investigacion = parseFloat(document.getElementById(‘investigacion’).value); const plazo = parseInt(document.getElementById(‘plazo’).value); if (isNaN(costoCasa) || isNaN(enganche) || isNaN(avaluo) || isNaN(investigacion) || isNaN(plazo)) { alert(‘Por favor, complete todos los campos correctamente.’); return; } const montoAval = costoCasa * avaluo; const comisionApertura = costoCasa * 0.01; const gastosInvestigacion = costoCasa * investigacion; const gastosNotariales = costoCasa * 0.07; const desembolsoTotal = enganche + montoAval + comisionApertura + gastosInvestigacion + gastosNotariales; const montoCredito = costoCasa – enganche; const tasaInteresAnual = 0.1; const tasaMensual = tasaInteresAnual / 12; const meses = plazo * 12; const pagoMensual = (montoCredito * tasaMensual) / (1 – Math.pow(1 + tasaMensual, -meses)); document.getElementById(‘resultado’).innerHTML = `
Desembolso Total (Primer Pago): $${desembolsoTotal.toFixed(2)}
Pago Mensual: $${pagoMensual.toFixed(2)}
`; }
body {
font-family: Arial, sans-serif;
margin: 20px;
}
label {
display: block;
margin: 10px 0 5px;
}
input, select, button {
margin-bottom: 15px;
padding: 8px;
width: 100%;
max-width: 400px;
box-sizing: border-box;
}
.result {
margin-top: 20px;
padding: 10px;
background-color: #f0f0f0;
border-radius: 5px;
}