From dff34fbbf89da28e5c62075c3a1fbab177a98030 Mon Sep 17 00:00:00 2001 From: PeraltaAlexis <30517134+PeraltaAlexis@users.noreply.github.com> Date: Sat, 26 Aug 2017 07:51:34 -0600 Subject: [PATCH 1/4] 26/08/2017 --- EF1.java | 33 +++++++++++++++++++-------------- EF2.java | 44 +++++++++++++++++++++++++++++++++++--------- 2 files changed, 54 insertions(+), 23 deletions(-) diff --git a/EF1.java b/EF1.java index 66ebb69..096f603 100644 --- a/EF1.java +++ b/EF1.java @@ -1,15 +1,20 @@ -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]); + + class Factorial{ + public int Factorial(int m){ + if (m == 0){ + return 1; + } + else{ + return m*Factorial(m-1); + } + } + } + Factorial resultado = new Factorial(); + + System.out.println(resultado.Factorial(n)); + } } \ No newline at end of file diff --git a/EF2.java b/EF2.java index c70e201..c1bec6e 100644 --- a/EF2.java +++ b/EF2.java @@ -1,9 +1,35 @@ -public class EF2{ - - public static void main(String args[]){ - - - } - - -} \ No newline at end of file +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}; + EF2 bub = new EF2(); + bub.sort(array); + bub.print(array); + } + + public void sort(int array[]){ + + for (int i = 0 ; i < array.length ; i++) { + for (int j = 1 ; j < array.length-i ; j=(1+j)) { + if (array [j-1] > array[j]) { + int temp = array[j-1]; + array[j-1] = array[j]; + array[j] = temp; + } + } + } + } + + public void print (int array[]) { + System.out.print("{"); + for (int i = 0 ; i < array.length ; i++){ + System.out.print(array[i]); + if (i < array.length -1){ + System.out.print(", "); + } + else { + System.out.print("}"); + } + } + } +} From 0300343c93205fc45ebef6d8981de5381cbf9ff9 Mon Sep 17 00:00:00 2001 From: PeraltaAlexis <30517134+PeraltaAlexis@users.noreply.github.com> Date: Sun, 10 Sep 2017 13:57:51 -0500 Subject: [PATCH 2/4] EF4 --- EF4.java | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 EF4.java diff --git a/EF4.java b/EF4.java new file mode 100644 index 0000000..64325df --- /dev/null +++ b/EF4.java @@ -0,0 +1,85 @@ +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import javax.swing.JFrame; +import javax.swing.WindowConstants; +import javax.swing.JTextField; +import javax.swing.JLabel; +import javax.swing.JButton; + +public class EF4 extends JFrame implements ActionListener{ + + public static void main(String args[]){ + EF4 ventana = new EF4(); + ventana.campoTexto(); + ventana.show(); + ventana.paintAll(ventana.getGraphics()); + + } + + public EF4(){ + setSize(250, 300); + setTitle("Sumadora"); + setLayout(null); + setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + setResizable(false); + + } + + private JTextField Campo; + private JLabel label1; + private JButton boton; + private JLabel label2; + + public void campoTexto(){ + Campo = new JTextField("0"); + Campo.setBounds(75,100,100,25); + Campo.setEditable(true); + Campo.setHorizontalAlignment(JTextField.RIGHT); + this.add(Campo); + + label1 = new JLabel(); + label1.setText("Ingrese los valores:"); + label1.setBounds(70, 60, 150, 25); + this.add(label1); + + boton = new JButton(); + boton.setText("Suma"); + boton.setBounds(75, 140, 100, 25); + boton.addActionListener(this); + this.add(boton); + + label2 = new JLabel(); + label2.setBounds(75, 180, 100, 25); + label2.setText(""); + this.add(label2); + + } + + @Override + public void actionPerformed(ActionEvent e){ + + String res = this.getSuma(Campo.getText()); + + label2.setText("Resultado: " + res); + } + + public String getSuma(String entrada){ + + String[] numeros = entrada.split(","); + + + int suma = 0; + //Realizar suma + int temp = 0; + for(String numero:numeros) + { + int a = Integer.parseInt(numero); + suma = temp + a; + temp = suma; + + } + return suma+""; + + } + +} From 024ee01fea0dfe4cee536d1988250a9cd9ae3bf0 Mon Sep 17 00:00:00 2001 From: PeraltaAlexis <30517134+PeraltaAlexis@users.noreply.github.com> Date: Sun, 10 Sep 2017 14:09:36 -0500 Subject: [PATCH 3/4] Delete EF4.java --- EF4.java | 85 -------------------------------------------------------- 1 file changed, 85 deletions(-) delete mode 100644 EF4.java diff --git a/EF4.java b/EF4.java deleted file mode 100644 index 64325df..0000000 --- a/EF4.java +++ /dev/null @@ -1,85 +0,0 @@ -import java.awt.event.ActionListener; -import java.awt.event.ActionEvent; -import javax.swing.JFrame; -import javax.swing.WindowConstants; -import javax.swing.JTextField; -import javax.swing.JLabel; -import javax.swing.JButton; - -public class EF4 extends JFrame implements ActionListener{ - - public static void main(String args[]){ - EF4 ventana = new EF4(); - ventana.campoTexto(); - ventana.show(); - ventana.paintAll(ventana.getGraphics()); - - } - - public EF4(){ - setSize(250, 300); - setTitle("Sumadora"); - setLayout(null); - setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - setResizable(false); - - } - - private JTextField Campo; - private JLabel label1; - private JButton boton; - private JLabel label2; - - public void campoTexto(){ - Campo = new JTextField("0"); - Campo.setBounds(75,100,100,25); - Campo.setEditable(true); - Campo.setHorizontalAlignment(JTextField.RIGHT); - this.add(Campo); - - label1 = new JLabel(); - label1.setText("Ingrese los valores:"); - label1.setBounds(70, 60, 150, 25); - this.add(label1); - - boton = new JButton(); - boton.setText("Suma"); - boton.setBounds(75, 140, 100, 25); - boton.addActionListener(this); - this.add(boton); - - label2 = new JLabel(); - label2.setBounds(75, 180, 100, 25); - label2.setText(""); - this.add(label2); - - } - - @Override - public void actionPerformed(ActionEvent e){ - - String res = this.getSuma(Campo.getText()); - - label2.setText("Resultado: " + res); - } - - public String getSuma(String entrada){ - - String[] numeros = entrada.split(","); - - - int suma = 0; - //Realizar suma - int temp = 0; - for(String numero:numeros) - { - int a = Integer.parseInt(numero); - suma = temp + a; - temp = suma; - - } - return suma+""; - - } - -} From 9ebeb8c775e336c4d67acdbf1c68b3ff5194129d Mon Sep 17 00:00:00 2001 From: PeraltaAlexis <30517134+PeraltaAlexis@users.noreply.github.com> Date: Sun, 10 Sep 2017 14:10:20 -0500 Subject: [PATCH 4/4] EF4 --- EF4.java | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 EF4.java diff --git a/EF4.java b/EF4.java new file mode 100644 index 0000000..64325df --- /dev/null +++ b/EF4.java @@ -0,0 +1,85 @@ +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import javax.swing.JFrame; +import javax.swing.WindowConstants; +import javax.swing.JTextField; +import javax.swing.JLabel; +import javax.swing.JButton; + +public class EF4 extends JFrame implements ActionListener{ + + public static void main(String args[]){ + EF4 ventana = new EF4(); + ventana.campoTexto(); + ventana.show(); + ventana.paintAll(ventana.getGraphics()); + + } + + public EF4(){ + setSize(250, 300); + setTitle("Sumadora"); + setLayout(null); + setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + setResizable(false); + + } + + private JTextField Campo; + private JLabel label1; + private JButton boton; + private JLabel label2; + + public void campoTexto(){ + Campo = new JTextField("0"); + Campo.setBounds(75,100,100,25); + Campo.setEditable(true); + Campo.setHorizontalAlignment(JTextField.RIGHT); + this.add(Campo); + + label1 = new JLabel(); + label1.setText("Ingrese los valores:"); + label1.setBounds(70, 60, 150, 25); + this.add(label1); + + boton = new JButton(); + boton.setText("Suma"); + boton.setBounds(75, 140, 100, 25); + boton.addActionListener(this); + this.add(boton); + + label2 = new JLabel(); + label2.setBounds(75, 180, 100, 25); + label2.setText(""); + this.add(label2); + + } + + @Override + public void actionPerformed(ActionEvent e){ + + String res = this.getSuma(Campo.getText()); + + label2.setText("Resultado: " + res); + } + + public String getSuma(String entrada){ + + String[] numeros = entrada.split(","); + + + int suma = 0; + //Realizar suma + int temp = 0; + for(String numero:numeros) + { + int a = Integer.parseInt(numero); + suma = temp + a; + temp = suma; + + } + return suma+""; + + } + +}