Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(cargarEventos);
- function cargarEventos(){
- $("#btnEj1").click(negativoOPositivo); // Ejercicio 1
- $("#btnEj2").click(mayorQue10);
- $("#btnEj3").click(mayorOIgualQue20);
- $("#btnEj4").click(convertirPositivo);
- $("#btnEj5").click(entre10y20);
- $("#btnEj6").click(multiplo7y3);
- $("#btnEj7").click(fueraDeMenos20y20);
- $("#btnEj8").click(entre10y30);
- $("#btnEj9").click(plan);
- $("#btnEj10").click(restar);
- }
- //Ejercicio 1------------------------------------------------------------
- function negativoOPositivo(){
- let valorEj1 = $("#txtNumeroEj1").val();
- valorEj1 = parseInt(valorEj1);
- let mensaje = "El numero es negativo";
- if (valorEj1 > 0) {
- mensaje = "El numero es positivo";
- }
- $("#divMostrarEj1").html(mensaje);
- }
- //Ejercicio 2------------------------------------------------------------
- function mayorQue10() {
- let valorEj2 = $("#txtNumeroEj2").val();
- valorEj2 = parseInt(valorEj2);
- let mensaje = "Mayor a 10";
- if (valorEj2 > 10) {
- $("#divMostrarEj2").html(mensaje);
- }
- }
- //Ejercicio 3------------------------------------------------------------
- function mayorOIgualQue20() {
- let valorEj3 = $("#txtNumeroEj3").val();
- valorEj3 = parseInt(valorEj3);
- let mensaje = "Mayor a 20";
- if (valorEj3 <= 20) {
- mensaje = "Es menor o igual a 20"
- }
- $("#divMostrarEj3").html(mensaje);
- }
- //Ejercicio 4------------------------------------------------------------
- function convertirPositivo() {
- let valorEj4 = $("#txtNumeroEj4").val();
- valorEj4 = parseInt(valorEj4);
- if (valorEj4 < 0) {
- valorEj4 = valorEj4 * -1;
- }
- $("#divMostrarEj4").html("El valor absoluto del numero ingresado es: " + valorEj4);
- }
- //Ejercicio 5------------------------------------------------------------
- function entre10y20() {
- let valorEj5 = $("#txtNumeroEj5").val();
- valorEj5 = parseInt(valorEj5);
- let mensaje = "No"
- if (valorEj5 > 10 & valorEj5 < 20) {
- mensaje = "Si";
- }
- $("#divMostrarEj5").html(mensaje);
- }
- //Ejercicio 6------------------------------------------------------------
- function multiplo7y3() {
- let valorEj6 = $("#txtNumeroEj6").val();
- valorEj6 = parseInt(valorEj6);
- let mensaje = "No"
- if (valorEj6 % 7 === 0 & valorEj6 % 3 === 0) {
- mensaje = "Si";
- }
- $("#divMostrarEj6").html(mensaje);
- }
- //Ejercicio 7------------------------------------------------------------
- function fueraDeMenos20y20() {
- let valorEj7 = $("#txtNumeroEj7").val();
- valorEj7 = parseInt(valorEj7);
- let mensaje = "No"
- if (valorEj7 < -20 | valorEj7 > 20) {
- mensaje = "Si";
- }
- $("#divMostrarEj7").html(mensaje);
- }
- //Ejercicio 8------------------------------------------------------------
- function entre10y30() {
- let valorEj8 = $("#txtNumeroEj8").val();
- valorEj8 = parseInt(valorEj8);
- let mensaje = "El valor ingresado se encuentra entre 10 y 30";
- if (valorEj8 < 10) {
- mensaje = "El valor ingresado es menor a 10";
- } else if (valorEj8 > 30) {
- mensaje = "El valor ingresado es mayor a 30";
- }
- $("#divMostrarEj8").html(mensaje);
- }
- //Ejercicio 9------------------------------------------------------------
- function plan() {
- let dia = $("#txtDia").val();
- let temp = $("#txtTemp").val();
- temp = parseInt(temp);
- let mensajeD = "Ir a trabajar";
- let mensajeT = "Ponerse ropa moderadamente abrigada";
- if (dia === "Domingo" | dia === "domingo") {
- mensajeD = "Quedarse en casa, hoy descansa";
- }
- if (temp < 10) {
- mensajeT = "Abrigarse mucho";
- } else if (temp > 20) {
- mensajeT = "Usar ropa comoda";
- }
- $("#divMostrarEj81").html("Levantarse");
- $("#divMostrarEj82").html(mensajeD);
- $("#divMostrarEj83").html(mensajeT);
- }
- //Ejercicio 10-----------------------------------------------------------
- function restar() {
- let val1 = $("#txtNumeroEj101").val();
- val1 = parseInt(val1);
- let val2 = $("#txtNumeroEj102").val();
- val2 = parseInt(val2);
- let resultado = 0;
- if (val1 > val2) {
- resultado = val1 - val2;
- } else {
- resultado = val2 - val1;
- }
- $("#divMostrarEj10").html(resultado);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement