From bcc8aa25ea3cfd1bb2edb1433aeb6cc547d9066c Mon Sep 17 00:00:00 2001 From: deathstroke021 Date: Sat, 26 Aug 2017 12:51:03 -0600 Subject: [PATCH 1/3] Ejercicios para 26/8/2017 --- .gitignore | 2 ++ EF1.java | 24 ++++++++++++------------ EF2.java | 36 +++++++++++++++++++++++++++++------- 3 files changed, 43 insertions(+), 19 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c67bb18 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +EF1.class +EF2.class \ No newline at end of file diff --git a/EF1.java b/EF1.java index 66ebb69..b35f28b 100644 --- a/EF1.java +++ b/EF1.java @@ -1,15 +1,15 @@ public class EF1{ - - public static void main(String args[]){ - int n = Integer.parseInt(args[0]); - System.out.println(Factorial(n)); - } + + public static void main(String args[]){ + int numero = Integer.parseInt(args[0]); + System.out.println(Factorial(numero)); + } - public static int Factorial(int n){ - if(){//Escribir condición de salida - return 1; - }else{//Escribir el retorno para la recursividad + public static int Factorial(int numero){ + if(numero==1 || numero==0){ + return 1; + }else{return numero*Factorial(numero-1); - } - } -} \ No newline at end of file + } + } +} diff --git a/EF2.java b/EF2.java index c70e201..bcadf81 100644 --- a/EF2.java +++ b/EF2.java @@ -1,9 +1,31 @@ -public class EF2{ - - public static void main(String args[]){ - - - } +public class EF2 { + public static void main(String[] args) { + int arr[] = {2, 3, 8, 109, 13, 4, 18, 10, 23, 18, 50, 11, 13, 2}; + EF2 arreglo = new EF2(); + arreglo.sort(arr); + arreglo.imprimir(arr); + } + public void sort(int arr []){ + for(int i = 0; i < (arr.length); i++){ + for (int j = 1; j < (arr.length-i);j++){ + if (arr[j-1] > arr [j]){ + int temp = arr [j]; + arr [j] = arr [j-1]; + arr [j-1] = temp; + } + } + } + } + + public void imprimir(int arr []){ + System.out.print("{"); + for (int i = 0; i < arr.length ; i++){ + System.out.print(arr[i]); + if (i!=(arr.length-1)) { + System.out.print(","); + } + } + System.out.println("}"); - +} } \ No newline at end of file From c5af1c546e3d833361e89d96bbbbea970aa5c6df Mon Sep 17 00:00:00 2001 From: deathstroke021 Date: Sat, 26 Aug 2017 13:16:55 -0600 Subject: [PATCH 2/3] Tarea Final --- EF1.java | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/EF1.java b/EF1.java index b35f28b..10633c7 100644 --- a/EF1.java +++ b/EF1.java @@ -1,15 +1,13 @@ public class EF1{ - - public static void main(String args[]){ - int numero = Integer.parseInt(args[0]); - System.out.println(Factorial(numero)); - } + public static void main(String args[]){ + int numero = Integer.parseInt(args[0]); + System.out.println(Factorial(numero)); + } + public static int Factorial(int numero){ + if(numero==1 || numero==0){ + return 1; + }else{return numero*Factorial(numero-1); - public static int Factorial(int numero){ - if(numero==1 || numero==0){ - return 1; - }else{return numero*Factorial(numero-1); - - } - } + } + } } From ac12560b239170891431c6c40c501540cd6e055e Mon Sep 17 00:00:00 2001 From: deathstroke021 Date: Sun, 10 Sep 2017 22:45:46 -0600 Subject: [PATCH 3/3] Ejercicio para 10/9/2017 --- .gitignore | 3 ++- EF4.java | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 EF4.java diff --git a/.gitignore b/.gitignore index c67bb18..7aa0cb8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ EF1.class -EF2.class \ No newline at end of file +EF2.class +EF4.class \ No newline at end of file diff --git a/EF4.java b/EF4.java new file mode 100644 index 0000000..9ba1ab4 --- /dev/null +++ b/EF4.java @@ -0,0 +1,57 @@ +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JTextField; +import javax.swing.WindowConstants; + +public class EF4 extends JFrame implements ActionListener{ + + public JButton btnBotonSumar = new JButton("SUMAR"); + public JLabel lblNumeros = new JLabel("INGRESE NUMEROS : "); + public JTextField txtNumeros = new JTextField(20); + public JLabel lblResultado = new JLabel(); + + public static void main(String args[]){ + EF4 ventana = new EF4(); + ventana.show(); + } + + public EF4(){ + setSize(250, 300); + setTitle("Sumadora"); + setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + setResizable(false); + this.btnBotonSumar.addActionListener(this); + FlowLayout DISTRIBUIDOR = new FlowLayout(FlowLayout.CENTER,30,30); + this.setLayout(DISTRIBUIDOR); + this.add(this.lblNumeros); + this.add(this.txtNumeros); + this.add(this.btnBotonSumar); + this.add(this.lblResultado); + } + + public String getSuma(String entrada){ + String[] numeros = entrada.split(","); + int suma = 0; + //Realizar suma + for(String numero:numeros) + { + suma += Integer.parseInt(numero); + } + return "Resultado:" +suma+ ""; + } + + @Override + public void actionPerformed(ActionEvent AE) + { + if(AE.getSource() == this.btnBotonSumar) + { + String entrada = txtNumeros.getText(); + lblResultado.setText(getSuma(entrada)); + } + + } +} \ No newline at end of file