Last active
August 29, 2015 14:18
-
-
Save Gonzalo2683/47004b59d0c7748911dd to your computer and use it in GitHub Desktop.
Práctica Uno , usos de variables y obtención de valores de las variables de un input.
This file contains 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> | |
<head> | |
<title>Variables y Operadores Aritméticos</title> | |
<meta charset="UTF-8"> | |
<script src="js/jquery/dist/jquery.js" type="text/javascript"></script> | |
<script src="js/variables.js" type="text/javascript"></script> | |
</head> | |
<body> | |
<h4>Mostrar apellido y nombre</h4> | |
Nombre:<input type="text" id="txtNombre" /> | |
Apellido:<input type="text" id="txtApellido" /> | |
<input type="button" id="btnMostrarNombre" value="Mostar"/> | |
<div id="divMostrarNombre"></div> | |
<hr /> | |
<h4>Sumar dos valores</h4> | |
Valor 1:<input type="text" id="numValor1" /> | |
Valor 2:<input type="text" id="numValor2" /> | |
<input type="button" id="btnSumaValores" value="Sumar"/> | |
<div id="divMostrarSuma"> | |
</div> | |
<hr /> | |
<h4>Sumar tres valores</h4> | |
Número 1:<input type="text" id="numUno" /> | |
Número 2:<input type="text" id="numDos" /> | |
Número 3:<input type="text" id="numTres" /> | |
<input type="button" id="btnSumaTresValores" value="Sumar"/> | |
<div id="divSumaTresValores"> | |
</div> | |
<hr /> | |
<h4>Sumar dos valores y multiplica</h4> | |
Número 1:<input type="text" id="valUno" /> | |
Número 2:<input type="text" id="valDos" /> | |
<input type="button" id="btnSumaMultiplica" value="Sumar"/> | |
<div> | |
<h5>Suma</h5> | |
<div id="divSumaDosVal"></div> | |
<h5>Multiplicación</h5> | |
<div id="divMulDosVal"></div> | |
</div> | |
<hr /> | |
<h4>Calcular el área del cuadrado</h4> | |
Longitud del lado:<input type="text" id="valorLado" /> | |
<input type="button" id="btnAreaCuadrado" value="Calcular Área"/> | |
<div> | |
<h5>Area cuadrado</h5> | |
<div id="divAreaCuadrado"></div> | |
</div> | |
<hr /> | |
<h4>Cálcular el Tipo de cambio de dólares a pesos Uruguayos</h4> | |
<p>Al día sábado 11 de abril de 2015 los valores del dolar son los siguientes:</p> | |
<p>Compra: 25.95, Venta 26.75</p> | |
Ingrese valor en pesos: <input type="text" id="valorPesosUy"/> | |
<input type="button" id="btnCalcDolares" value="Convertir a Dólares"/> | |
<h5>Compra</h5> | |
<div id="divResultCompra"> | |
</div> | |
<h5>Venta</h5> | |
<div id="divResultVenta"></div> | |
<hr /> | |
<h4>Acumular valor</h4> | |
Ingrese valor: <input type="text" id="valorIngresado"/> | |
<input type="button" id="btnAcumular" value="Acumular"/> | |
<input type="button" id="btnMostrarAcumulado" value="Mostrar Acumulado"/> | |
<h5>Se acumuló</h5><br/> | |
<div id="divAcumulado"></div> | |
<hr /> | |
<h4>Mostrar Resto</h4> | |
Valor 1:<input type="text" id="valorIngresoUno"/> | |
Valor 2:<input type="text" id="valorIngresoDos"/> | |
<input type="button" id="btnVerResto" value="Ver Resto"/> | |
<h5>Resto</h5> | |
<div id="divResto"></div> | |
<hr /> | |
<h4>Sumar dos valores y restar el último</h4> | |
Valor 1:<input type="text" id="valorEntrada1"/> | |
Valor 2:<input type="text" id="valorEntrada2"/> | |
Valor 3:<input type="text" id="valorEntrada3"/> | |
<input type="button" id="btnCalculaSumRest" value="Ver resultado"/> | |
<h5>Resultado</h5> | |
<div id="divSumRest"></div> | |
<hr /> | |
<h4>El primero elevado al cuadrado menos la suma de los otros dos</h4> | |
Valor 1:<input type="text" id="entradaUno"/> | |
Valor 2:<input type="text" id="entradaDos"/> | |
Valor 3:<input type="text" id="entradaTres"/> | |
<input type="button" id="btnCuadradoMinus" value="Ver resultado"/> | |
<h5>Resultado</h5> | |
<div id="divSqrMinus"></div> | |
<hr /> | |
<h4>Calcular importe</h4> | |
Valor:<input type="text" id="valorIngreso"/> | |
Importe:<input type="text" id="valorImporte"/> | |
<input type="button" id="btnCalcImporte" value="Calcular Importe"/> | |
<h5>Resultado</h5> | |
<div id="divImporte"></div> | |
<hr /> | |
<h4>Calcular importe con IVA</h4> | |
Importe:<input type="text" id="valorSinIva"/> | |
<input type="button" id="btnCalcMasIva" value="Calcular Importe más IVA"/> | |
<h5>Resultado</h5> | |
<div id="divImporteIva"></div> | |
<hr /> | |
<h4>Cálculo de IMC</h4> | |
Peso:<input type="text" id="valorPeso"/> | |
Altura:<input type="text" id="valorAltura"/> | |
<input type="button" id="btnCalcImc" value="Calcular IMC"/> | |
<h5>Resultado</h5> | |
<div id="divImc"></div> | |
<hr /> | |
<h4>Calcular Temperatura</h4> | |
Número de chirridos:<input type="text" id="numChirridos"/> | |
<input type="button" id="btnFahrenheit" value="Ver Temperatura en Fahrenheit"/> | |
<input type="button" id="btnCelsius" value="Transformar a Celsius"/> | |
<h5>Resultado en Fahrenhiet</h5> | |
<div id="divFahrenheit"></div> | |
<h5>Resultado en Celsius</h5> | |
<div id="divCelsius"></div> | |
</body> | |
</html> |
This file contains 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
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
$(document).ready(inicio); | |
var acumulado = 0; | |
function inicio(){ | |
document.getElementById('btnMostrarNombre').onclick = mostrarNombre; | |
document.getElementById('btnSumaValores').onclick = suma; | |
document.getElementById('btnSumaTresValores').onclick = sumaTres; | |
document.getElementById('btnSumaMultiplica').onclick = SumaMultiplica; | |
document.getElementById('btnAreaCuadrado').onclick = areaCuadrado; | |
document.getElementById('btnCalcDolares').onclick = cambioDolares; | |
document.getElementById('btnAcumular').onclick = acumularValor; | |
document.getElementById('btnVerResto').onclick = calculaResto; | |
document.getElementById('btnCalculaSumRest').onclick = sumaResta; | |
document.getElementById('btnCuadradoMinus').onclick = sqrMinus; | |
document.getElementById('btnCalcImporte').onclick = calcularImporte; | |
document.getElementById('btnCalcMasIva').onclick = calcImporteMasIva; | |
document.getElementById('btnCalcImc').onclick = calcularImc; | |
document.getElementById('btnFahrenheit').onclick = obtenerTemperatura; | |
document.getElementById('btnMostrarAcumulado').onclick = muestraAcumuldado; | |
} | |
function mostrarNombre(){ | |
var nombre = document.getElementById('txtNombre').value; | |
var apellido = document.getElementById('txtApellido').value; | |
var nombreCompleto = apellido + ", " + nombre; | |
var divResultado = document.getElementById('divMostrarNombre'); | |
divResultado.innerHTML = nombreCompleto; | |
} | |
function suma(){ | |
var valorUno = parseInt(document.getElementById('numValor1').value); | |
var valorDos = parseInt(document.getElementById('numValor2').value); | |
var divResultadoSuma = document.getElementById('divMostrarSuma'); | |
var sumaTotal = valorUno + valorDos; | |
divResultadoSuma.innerHTML = sumaTotal; | |
} | |
function sumaTres(){ | |
var valorUno = parseInt(document.getElementById('numUno').value); | |
var valorDos = parseInt(document.getElementById('numDos').value); | |
var valorTres = parseInt(document.getElementById('numTres').value); | |
var sumaTotalTresValores = valorUno + valorDos + valorTres; | |
var divResultadoSum = document.getElementById('divSumaTresValores'); | |
divResultadoSum.innerHTML = sumaTotalTresValores; | |
} | |
function SumaMultiplica(){ | |
var valorUno = 0; | |
var valorDos = 0; | |
var sumaTotal = 0; | |
var multTotal = 0; | |
var divResultadoSum = 0; | |
var divResultadoMult = 0; | |
divResultadoSum = document.getElementById('divSumaDosVal'); | |
divResultadoMult = document.getElementById('divMulDosVal'); | |
valorUno = parseInt(document.getElementById('valUno').value); | |
valorDos = parseInt(document.getElementById('valDos').value); | |
sumaTotal = valorUno + valorDos; | |
multTotal = (valorUno * valorDos); | |
divResultadoSum.innerHTML = sumaTotal; | |
divResultadoMult.innerHTML = multTotal; | |
} | |
function areaCuadrado() { | |
var valorLado = document.getElementById('valorLado').value; | |
var divResultArea = document.getElementById('divAreaCuadrado'); | |
var areaResult = valorLado * valorLado; | |
divResultArea.innerHTML = areaResult; | |
} | |
function cambioDolares() { | |
var dolarCompra = 25.95; | |
var dolarVenta = 26.75; | |
var valorPesos = document.getElementById('valorPesosUy').value; | |
var divCompra = document.getElementById('divResultCompra'); | |
var divVenta = document.getElementById('divResultVenta'); | |
var resultCompra = valorPesos / dolarCompra; | |
var resultVenta = valorPesos / dolarVenta; | |
divCompra.innerHTML = resultCompra; | |
divVenta.innerHTML = resultVenta; | |
} | |
function acumularValor() { | |
var valorIngreso = parseInt(document.getElementById('valorIngresado').value); | |
acumulado = acumulado + valorIngreso; | |
} | |
function muestraAcumuldado () { | |
var divAcumulado = document.getElementById('divAcumulado'); | |
divAcumulado.innerHTML = acumulado; | |
//acumulado = 0; | |
} | |
function calculaResto(){ | |
var divResto = document.getElementById('divResto'); | |
var valorEntradaUno = document.getElementById('valorIngresoUno').value; | |
var valorEntradaDos = document.getElementById('valorIngresoDos').value; | |
var resto = valorEntradaUno % valorEntradaDos; | |
divResto.innerHTML = resto; | |
} | |
function sumaResta(){ | |
var divSumRest = document.getElementById('divSumRest'); | |
var entradaUno = parseInt(document.getElementById('valorEntrada1').value); | |
var entradaDos = parseInt(document.getElementById('valorEntrada2').value); | |
var entradaTres = parseInt(document.getElementById('valorEntrada3').value); | |
var resultadoSumRest = (entradaUno + entradaDos) - entradaTres; | |
divSumRest.innerHTML = resultadoSumRest; | |
} | |
function sqrMinus(){ | |
var divCuadradoMinus = document.getElementById('divSqrMinus'); | |
var valorEntradaUno = parseInt(document.getElementById('entradaUno').value); | |
var valorEntradaDos = parseInt(document.getElementById('entradaDos').value); | |
var valorEntradaTres = parseInt(document.getElementById('entradaTres').value); | |
var resultCuadradoMinus = (valorEntradaUno * valorEntradaUno) - (valorEntradaDos + valorEntradaTres); | |
divCuadradoMinus.innerHTML = resultCuadradoMinus; | |
} | |
function calcularImporte(){ | |
var divImporte = document.getElementById('divImporte'); | |
var valorIngreso = document.getElementById('valorIngreso').value; | |
var valorImporte = document.getElementById('valorImporte').value; | |
var importeResult = (valorIngreso * valorImporte)/100; | |
divImporte.innerHTML = importeResult; | |
} | |
function calcImporteMasIva() { | |
var iva = 22; | |
var divIva = document.getElementById('divImporteIva'); | |
var valorSinIva = parseInt(document.getElementById('valorSinIva').value); | |
var resultConIva = ((valorSinIva * iva)/100) + valorSinIva; | |
divIva.innerHTML = resultConIva; | |
} | |
function calcularImc(){ | |
var divImc = document.getElementById('divImc'); | |
var valorPeso = document.getElementById('valorPeso').value; | |
var valorAltura = document.getElementById('valorAltura').value; | |
var imc = (valorPeso)/(valorAltura * valorAltura); | |
divImc.innerHTML = imc; | |
} | |
function obtenerTemperatura(){ | |
var numChirridos = document.getElementById('numChirridos').value; | |
var divFahrenheit = document.getElementById('divFahrenheit'); | |
var divCelsius = document.getElementById('divCelsius'); | |
var resulFahrenheit = 50 +( (numChirridos - 40) / 4 ); | |
var resulCelsius = (resulFahrenheit - 32)* 5/9; | |
divFahrenheit.innerHTML = resulFahrenheit; | |
document.getElementById('btnCelsius').onclick = enCelsius; | |
function enCelsius(){ | |
divCelsius.innerHTML = resulCelsius; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment