Last active
March 7, 2025 10:07
-
-
Save 9xbt/77ca372623a00e24f4cdbf9175e258b4 to your computer and use it in GitHub Desktop.
Calculadora de beneficios
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Calculadora de Beneficios</title> | |
<style> | |
body { | |
font-family: Arial, sans-serif; | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
height: 100vh; | |
background-color: #f0f0f0; | |
} | |
.calculator { | |
background-color: #fff; | |
padding: 20px; | |
border-radius: 8px; | |
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); | |
} | |
.calculator h1 { | |
margin-bottom: 20px; | |
} | |
.calculator label { | |
display: block; | |
margin: 10px 0 5px; | |
} | |
.calculator input { | |
width: 100%; | |
padding: 8px; | |
box-sizing: border-box; | |
} | |
.calculator button { | |
margin-top: 20px; | |
padding: 10px 15px; | |
background-color: #007bff; | |
color: #fff; | |
border: none; | |
border-radius: 4px; | |
cursor: pointer; | |
} | |
.calculator button:hover { | |
background-color: #0056b3; | |
} | |
.calculator .result { | |
margin-top: 20px; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="calculator"> | |
<h1>Calculadora de Beneficios</h1> | |
<label for="initialCapital">Capital Inicial:</label> | |
<input type="number" id="initialCapital" placeholder="Ingresa el capital inicial"> | |
<label for="dailyPercentage">Porcentaje Diario (%):</label> | |
<input type="number" id="dailyPercentage" placeholder="Ingresa el porcentaje diario"> | |
<label for="targetProfit">Beneficio Objetivo:</label> | |
<input type="number" id="targetProfit" placeholder="Ingresa el beneficio objetivo"> | |
<button onclick="calculateDays()">Calcular Días</button> | |
<div class="result" id="result"></div> | |
</div> | |
<script> | |
function calculateDays() { | |
const initialCapital = parseFloat(document.getElementById('initialCapital').value); | |
const dailyPercentage = parseFloat(document.getElementById('dailyPercentage').value) / 100; | |
const targetProfit = parseFloat(document.getElementById('targetProfit').value); | |
if (isNaN(initialCapital) || isNaN(dailyPercentage) || isNaN(targetProfit)) { | |
alert('Por favor, ingresa valores válidos.'); | |
return; | |
} | |
let days = 0; | |
let capital = initialCapital; | |
while (capital < initialCapital + targetProfit) { | |
capital += capital * dailyPercentage; | |
days++; | |
} | |
document.getElementById('result').innerText = `Tardarás ${days} días en alcanzar tu objetivo de beneficio.`; | |
} | |
</script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Calculadora de Crecimiento de Capital</title> | |
<style> | |
body { | |
font-family: Arial, sans-serif; | |
max-width: 600px; | |
margin: 0 auto; | |
padding: 20px; | |
} | |
h1 { | |
text-align: center; | |
} | |
label { | |
display: block; | |
margin-top: 10px; | |
} | |
input { | |
width: 100%; | |
padding: 8px; | |
margin-top: 5px; | |
} | |
button { | |
display: block; | |
width: 100%; | |
padding: 10px; | |
margin-top: 20px; | |
background-color: #4CAF50; | |
color: white; | |
border: none; | |
cursor: pointer; | |
} | |
button:hover { | |
background-color: #45a049; | |
} | |
#result { | |
margin-top: 20px; | |
font-weight: bold; | |
} | |
</style> | |
</head> | |
<body> | |
<h1>Calculadora de Crecimiento de Capital</h1> | |
<form id="capitalForm"> | |
<label for="initialCapital">Capital Inicial:</label> | |
<input type="number" id="initialCapital" required> | |
<label for="dailyPercentage">Porcentaje Diario (%):</label> | |
<input type="number" id="dailyPercentage" required> | |
<label for="targetCapital">Capital Objetivo:</label> | |
<input type="number" id="targetCapital" required> | |
<button type="button" onclick="calculateDays()">Calcular</button> | |
</form> | |
<div id="result"></div> | |
<script> | |
function calculateDays() { | |
const initialCapital = parseFloat(document.getElementById('initialCapital').value); | |
const dailyPercentage = parseFloat(document.getElementById('dailyPercentage').value) / 100; | |
const targetCapital = parseFloat(document.getElementById('targetCapital').value); | |
if (isNaN(initialCapital) || isNaN(dailyPercentage) || isNaN(targetCapital)) { | |
alert('Por favor, ingrese valores válidos.'); | |
return; | |
} | |
let days = 0; | |
let currentCapital = initialCapital; | |
while (currentCapital < targetCapital) { | |
currentCapital += currentCapital * dailyPercentage; | |
days++; | |
} | |
document.getElementById('result').innerText = `Se tardará ${days} días en alcanzar el capital objetivo.`; | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment