diff --git a/EF1.java b/EF1.java index 66ebb69..0c84ca8 100644 --- a/EF1.java +++ b/EF1.java @@ -1,15 +1,26 @@ -public class EF1{ - - public static void main(String args[]){ - int n = Integer.parseInt(args[0]); - System.out.println(Factorial(n)); - } - - public static int Factorial(int n){ - if(){//Escribir condición de salida - return 1; - }else{//Escribir el retorno para la recursividad - - } - } +public class EF1 { + + + public static void main(String[] args) { + + Scanner teclado = new Scanner(System.in); + System.out.println("Ingrese el número del cual desea saber el factorial"); + int numero = teclado.nextInt(); + Factorial(numero); + + } + + public static int Factorial(int numero){ + int r; + if(numero==0 || numero==1){ + r = 1; + }else{ + r = numero*Factorial(numero-1); + + } + + System.out.println("El factorial de "+numero+"es: "+r); + return r; + } + } \ No newline at end of file diff --git a/EF2.java b/EF2.java index c70e201..81d8cfa 100644 --- a/EF2.java +++ b/EF2.java @@ -1,9 +1,36 @@ -public class EF2{ - - public static void main(String args[]){ - - - } - - +public class EF2{ + + + public static void main(String[] args) { + + int array[] ={2, 3, 8, 109, 13, 4, 18, 10, 23, 18, 50, 11, 13, 2}; + BubbleSort bs= new BubbleSort(); + bs.sort(array); + bs.print(array); + + } + + public void sort(int array[]){ + + for(int i=0; i<=array.length; i++){ + for(int j=1; jarray[j]){ + int temp = array[j]; + array[j] = array[j-1]; + array[j-1]=temp; + } + } + } + + } + + public void print(int array[]){ + System.out.println("{"); + for(int i : array){ //Esto se conoce como foreach + System.out.print(i+","); + System.out.println(""); + } + System.out.println("}"); + } + } \ No newline at end of file diff --git a/EF3.java b/EF3.java new file mode 100644 index 0000000..e7d94af --- /dev/null +++ b/EF3.java @@ -0,0 +1,47 @@ +import java.util.Scanner; +import java.util.StringTokenizer; + + +public class EF3 { + + + public static void main(String[] args) { + + + String Opcion; + String Mensaje = ""; + String Encriptado = ""; + String Desencriptado = ""; + String Mensaje2 = ""; + float m,x,c,d; + + Scanner teclado = new Scanner(System.in); + + System.out.println("Ingrese el mensaje a encriptar"); + Opcion = teclado.next(); + + for(int i=0; i { + getSuma(Datos.getText()); + }); + + Panel.add(Resultado); + Resultado.setBounds(new Rectangle(150,75,200,25)); + } + + public void getSuma(String entrada){ + String[] numeros = entrada.split(","); + int suma=0; + + for(int i=0; i< numeros.length; i++){ + suma = suma + Integer.parseInt(numeros[i]); + } + Resultado.setText(Integer.toString(suma)); + + } +} \ No newline at end of file