Advertisement
Guest User

Untitled

a guest
Aug 30th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 4.34 KB | None | 0 0
  1. $(document).ready(cargarEventos);
  2.  
  3. function cargarEventos(){
  4.     $("#btnEj1").click(negativoOPositivo); // Ejercicio 1
  5.     $("#btnEj2").click(mayorQue10);
  6.     $("#btnEj3").click(mayorOIgualQue20);
  7.     $("#btnEj4").click(convertirPositivo);
  8.     $("#btnEj5").click(entre10y20);
  9.     $("#btnEj6").click(multiplo7y3);
  10.     $("#btnEj7").click(fueraDeMenos20y20);
  11.     $("#btnEj8").click(entre10y30);
  12.     $("#btnEj9").click(plan);
  13.     $("#btnEj10").click(restar);
  14. }
  15.  
  16. //Ejercicio 1------------------------------------------------------------
  17.  
  18. function negativoOPositivo(){
  19.     let valorEj1 = $("#txtNumeroEj1").val();
  20.     valorEj1 = parseInt(valorEj1);
  21.     let mensaje = "El numero es negativo";
  22.  
  23.     if (valorEj1 > 0) {
  24.         mensaje = "El numero es positivo";
  25.     }
  26.  
  27.     $("#divMostrarEj1").html(mensaje);
  28. }
  29.  
  30. //Ejercicio 2------------------------------------------------------------
  31.  
  32. function mayorQue10() {
  33.     let valorEj2 = $("#txtNumeroEj2").val();
  34.     valorEj2 = parseInt(valorEj2);
  35.     let mensaje = "Mayor a 10";
  36.  
  37.     if (valorEj2 > 10) {
  38.         $("#divMostrarEj2").html(mensaje);
  39.     }
  40. }
  41.  
  42. //Ejercicio 3------------------------------------------------------------
  43.  
  44. function mayorOIgualQue20() {
  45.     let valorEj3 = $("#txtNumeroEj3").val();
  46.     valorEj3 = parseInt(valorEj3);
  47.     let mensaje = "Mayor a 20";
  48.  
  49.     if (valorEj3 <= 20) {
  50.         mensaje = "Es menor o igual a 20"
  51.     }
  52.  
  53.     $("#divMostrarEj3").html(mensaje);
  54.  
  55. }
  56.  
  57. //Ejercicio 4------------------------------------------------------------
  58.  
  59. function convertirPositivo() {
  60.     let valorEj4 = $("#txtNumeroEj4").val();
  61.     valorEj4 = parseInt(valorEj4);
  62.  
  63.     if (valorEj4 < 0) {
  64.         valorEj4 = valorEj4 * -1;
  65.     }
  66.  
  67.     $("#divMostrarEj4").html("El valor absoluto del numero ingresado es: " + valorEj4);
  68.  
  69. }
  70.  
  71. //Ejercicio 5------------------------------------------------------------
  72.  
  73. function entre10y20() {
  74.     let valorEj5 = $("#txtNumeroEj5").val();
  75.     valorEj5 = parseInt(valorEj5);
  76.     let mensaje = "No"
  77.     if (valorEj5 > 10 & valorEj5 < 20) {
  78.         mensaje = "Si";
  79.     }
  80.     $("#divMostrarEj5").html(mensaje);
  81.  
  82. }
  83.  
  84. //Ejercicio 6------------------------------------------------------------
  85.  
  86. function multiplo7y3() {
  87.     let valorEj6 = $("#txtNumeroEj6").val();
  88.     valorEj6 = parseInt(valorEj6);
  89.     let mensaje = "No"
  90.     if (valorEj6 % 7 === 0 & valorEj6 % 3 === 0) {
  91.         mensaje = "Si";
  92.     }
  93.     $("#divMostrarEj6").html(mensaje);
  94.  
  95. }
  96.  
  97. //Ejercicio 7------------------------------------------------------------
  98.  
  99. function fueraDeMenos20y20() {
  100.     let valorEj7 = $("#txtNumeroEj7").val();
  101.     valorEj7 = parseInt(valorEj7);
  102.     let mensaje = "No"
  103.     if (valorEj7 < -20 | valorEj7 > 20) {
  104.         mensaje = "Si";
  105.     }
  106.     $("#divMostrarEj7").html(mensaje);
  107.  
  108. }
  109.  
  110. //Ejercicio 8------------------------------------------------------------
  111.  
  112. function entre10y30() {
  113.     let valorEj8 = $("#txtNumeroEj8").val();
  114.     valorEj8 = parseInt(valorEj8);
  115.     let mensaje = "El valor ingresado se encuentra entre 10 y 30";
  116.  
  117.     if (valorEj8 < 10) {
  118.         mensaje = "El valor ingresado es menor a 10";
  119.     } else if (valorEj8 > 30) {
  120.         mensaje = "El valor ingresado es mayor a 30";
  121.     }
  122.        
  123.     $("#divMostrarEj8").html(mensaje);
  124.  
  125. }
  126.  
  127. //Ejercicio 9------------------------------------------------------------
  128.  
  129. function plan() {
  130.     let dia = $("#txtDia").val();
  131.     let temp = $("#txtTemp").val();
  132.     temp = parseInt(temp);
  133.     let mensajeD = "Ir a trabajar";
  134.     let mensajeT = "Ponerse ropa moderadamente abrigada";
  135.  
  136.     if (dia === "Domingo" | dia === "domingo") {
  137.         mensajeD = "Quedarse en casa, hoy descansa";
  138.     }
  139.  
  140.     if (temp < 10) {
  141.         mensajeT = "Abrigarse mucho";
  142.     } else if (temp > 20) {
  143.         mensajeT = "Usar ropa comoda";
  144.     }
  145.  
  146.     $("#divMostrarEj81").html("Levantarse");
  147.     $("#divMostrarEj82").html(mensajeD);
  148.     $("#divMostrarEj83").html(mensajeT);
  149. }
  150.  
  151. //Ejercicio 10-----------------------------------------------------------
  152.  
  153. function restar() {
  154.     let val1 = $("#txtNumeroEj101").val();
  155.     val1 = parseInt(val1);
  156.     let val2 = $("#txtNumeroEj102").val();
  157.     val2 = parseInt(val2);
  158.     let resultado = 0;
  159.  
  160.     if (val1 > val2) {
  161.         resultado = val1 - val2;
  162.     } else {
  163.         resultado = val2 - val1;
  164.     }
  165.     $("#divMostrarEj10").html(resultado);
  166. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement