From 8b9f246e9e3ac79ff3d00dc2e50dcb32123b2ba2 Mon Sep 17 00:00:00 2001 From: Alejo972017Marin Date: Sat, 26 Aug 2017 14:44:49 -0600 Subject: [PATCH 1/3] Ejercicios para 26/8/2017 --- EF2.java | 51 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/EF2.java b/EF2.java index c70e201..02a39a7 100644 --- a/EF2.java +++ b/EF2.java @@ -1,9 +1,44 @@ -public class EF2{ - - public static void main(String args[]){ - - - } - - +public class EF2 { + + int tem; + + public static void main(String[] args) { + int array[] = {2,3,8,109,13,4,18,10,23,18,50,11,13,2}; + EF2 bs = new EF2(); + bs.Sort(array); + System.out.print("{"); + bs.print(array); + + } + + public void Sort(int array[]) { + for (int i = 0; i < (array.length); i++) { + for (int j = 1; j < (array.length); j++) { + if (array[j - 1] > array[j]) { + tem = array[j]; + array[j] = array[j - 1]; + array[j - 1] = tem; + + } + + } + } + + } + + public void print(int array[]) { + + for (int i = 0; i < array.length; i++) { + System.out.print(array[i]); + if (i != array.length - 1) { + System.out.print(","); + } + + } + + System.out.print("}"); + + System.out.println(""); + } + } \ No newline at end of file From 33ef2a078762ed4f79814761526b3dabf8a398a0 Mon Sep 17 00:00:00 2001 From: Alejo972017Marin Date: Sat, 26 Aug 2017 14:46:06 -0600 Subject: [PATCH 2/3] Ejercicios para 26/8/2017 --- EF1.java | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/EF1.java b/EF1.java index 66ebb69..4db31da 100644 --- a/EF1.java +++ b/EF1.java @@ -1,15 +1,24 @@ -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[]) { + + int N= Integer.parseInt(args[0]); + + System.out.println(Fact(N)); + } + + static int Fact(int N) { + + if (N <= 0) { + + return 1; + } else { + return N * (Fact(N - 1)); + } + + } + } \ No newline at end of file From f6d6d44440709c2f1a4859aff42d709c59d230e8 Mon Sep 17 00:00:00 2001 From: Alejo972017Marin Date: Sun, 10 Sep 2017 21:17:37 -0600 Subject: [PATCH 3/3] 10/09/2017 --- EF4.java | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 EF4.java diff --git a/EF4.java b/EF4.java new file mode 100644 index 0000000..fd79053 --- /dev/null +++ b/EF4.java @@ -0,0 +1,77 @@ +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.JOptionPane; +import javax.swing.JTextField; +import javax.swing.WindowConstants; + +public class EF4 extends JFrame { + + private JLabel Muestra; + private JTextField Datos; + private JButton Sumar; + + public static void main(String args[]) { + EF4 ventana = new EF4(); + ventana.setVisible(true); + ventana.show(); + } + + public EF4() { + setSize(250, 300); + setTitle("Sumadora"); + setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + setResizable(false); + + Datos = new JTextField(); + Muestra = new JLabel(""); + Sumar = new JButton("Sumar"); + + add("North", Datos); + add("Center", Muestra); + add("South", Sumar); + + Sumar.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent evt) { + SumarActionPerformed(evt); + } + + private void SumarActionPerformed(ActionEvent evt) { + + if (Datos.getText().equals("")) { + JOptionPane.showMessageDialog(null, "Introdusca Datos numericos "); + Datos.setText(" "); + + } else { + //Muestra.setText(Datos.getText()); + EF4 E = new EF4(); + E.getSuma(Datos.getText()); + Muestra.setText(E.getSuma(Datos.getText())); + //Datos.setText(" "); + } + + } + + }); + + } + + public String getSuma(String entrada) { + int suma = 0; + int sum=0; + String[] numeros = entrada.split(","); + //Realizar suma + for (String numero : numeros) { + + suma = Integer.parseInt(numero) + sum; + sum= suma; + } + + return suma + ""; + + } + +}