Created
February 23, 2022 22:44
-
-
Save joelibaceta/8eecc9450633b4b160da5bf7e75e4ecc to your computer and use it in GitHub Desktop.
CalculadoraAvance1
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
.btn { | |
width: 30px; | |
height: 30px; | |
border: 1px solid #dadada; | |
text-align: center; | |
cursor: pointer; | |
} | |
.fila { | |
display: flex; | |
} | |
#pantalla { | |
border: 1px solid #dadada; | |
text-align: right; | |
width: 116px; | |
height: 15px; | |
padding: 5px; | |
background-color: #eaeaea; | |
} |
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
<html> | |
<head> | |
<link rel="stylesheet" href="estilos.css" /> | |
</head> | |
<body> | |
<div class="calculadora"> | |
<div id="pantalla"> | |
0 | |
</div> | |
<div class="botones"> | |
<div class="fila"> | |
<div class="btn" onclick="clearScreen()"> CE </div> | |
<div class="btn"> DEL </div> | |
<div class="btn"> </div> | |
<div class="btn"> x </div> | |
</div> | |
<div class="fila"> | |
<div class="btn" onclick="numberSelected(this, 7)"> 7 </div> | |
<div class="btn" onclick="numberSelected(this, 8)"> 8 </div> | |
<div class="btn" onclick="numberSelected(this, 9)"> 9 </div> | |
<div class="btn"> - </div> | |
</div> | |
<div class="fila"> | |
<div class="btn" onclick="numberSelected(this, 4)"> 4 </div> | |
<div class="btn" onclick="numberSelected(this, 5)"> 5 </div> | |
<div class="btn" onclick="numberSelected(this, 6)"> 6 </div> | |
<div class="btn"> + </div> | |
</div> | |
<div class="fila"> | |
<div class="btn" onclick="numberSelected(this, 1)"> 1 </div> | |
<div class="btn" onclick="numberSelected(this, 2)"> 2 </div> | |
<div class="btn" onclick="numberSelected(this, 3)"> 3 </div> | |
<div class="btn"> / </div> | |
</div> | |
<div class="fila"> | |
<div class="btn" onclick="numberSelected(this, 0)"> 0 </div> | |
<div class="btn" onclick="numberSelected(this, '.')"> . </div> | |
<div class="btn"> </div> | |
<div class="btn"> = </div> | |
</div> | |
</div> | |
</div> | |
<script src="script.js" ></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
var screenText = ""; | |
var isDotUsed = false; | |
function clearScreen() { | |
screenText = ""; | |
updateScreen(); | |
} | |
function numberSelected(e, n) { | |
if (n == '.') { | |
if (isDotUsed == false ) { | |
screenText = screenText + n; | |
} | |
isDotUsed = true; | |
} else { | |
screenText = screenText + n; | |
} | |
updateScreen(); | |
} | |
function updateScreen() { | |
var pantalla = document.getElementById("pantalla"); | |
pantalla.textContent = screenText; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment