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
| /* | |
| * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license | |
| */ | |
| package com.mycompany.clasesjava; | |
| /** | |
| * | |
| * @author user | |
| */ |
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
| //INICIO ejercicio 3 | |
| //Ejercicio de números perfectos. Un número perfecto es aquel cuya suma de sus divisores propios (excluyendo él mismo) es igual al propio número. Por ejemplo, 28 es un número perfecto ya que sus divisores propios (1, 2, 4, 7, 14) suman 28. | |
| //Escribe un programa en Java que solicite al usuario ingresar un número y determine si es un número perfecto o no. | |
| System.out.println("Ejercicio 3"); | |
| Scanner scanner = new Scanner(System.in); | |
| System.out.println("Ingresa un numero"); | |
| int N=scanner.nextInt(); |
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
| //INICIO ejercicio 2 | |
| System.out.println("Ejercicio 2"); | |
| //Pedir los datos al usuario | |
| Scanner scanner = new Scanner(System.in); | |
| System.out.println("Ingresa un numero"); | |
| int N=scanner.nextInt(); | |
| //Saber la cantidad de digitos que tiene un numero |
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
| //INICIO ejercicio 1 | |
| int saldo=200000; | |
| int retiro=160000; | |
| if(saldo-retiro<0){ | |
| System.out.println("Pao, estas limpio, no puedes retirar esa cantidad"); | |
| } | |
| else | |
| { |
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
| //Acceder a valores de un objeto | |
| var miAuto ={ | |
| marca : "Toyota", | |
| modelo : "Corolla", | |
| annio: 2020, | |
| detalleDelAuto: function(){ | |
| console.log(`Auto ${this.modelo} ${this.annio}`); //Con this se accede en la misma creación del objeto | |
| } | |
| }; |
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 dulces = ["Chicle", "Barrilete", "Chocolatina", "Nucita"]; | |
| while (dulces.length > 0){ | |
| var dulce = dulces.shift(); | |
| console.log(dulce); | |
| } |
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 dulces = ["Chicle", "Barrilete", "Chocolatina", "Nucita"]; | |
| console.log(dulces.length); //Longitud del array | |
| console.log(dulces[0]); //Acceder a un elemento, en este caso el primero | |
| dulces.push("Frunas"); //Agregar un elemento al final | |
| console.log(dulces); | |
| dulces.pop(); //Eliminar el ultimo elemento | |
| console.log(dulces); |
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
| const numero = 1; | |
| switch (numero){ | |
| case 1: | |
| console.log("Soy uno"); | |
| break; | |
| case 2: | |
| console.log("Soy dos"); | |
| break | |
| default: |
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>Desestructuracion Objetos</title> | |
| </head> | |
| <body> | |
| <h1>Desestructuracion Objetos</h1> |
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>Desestructurar arreglos</title> | |
| </head> | |
| <body> | |
| <h1>Desestructuracion Arreglos</h1> |
NewerOlder