Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions EF1.java
Original file line number Diff line number Diff line change
@@ -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));
}
}
44 changes: 35 additions & 9 deletions EF2.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,35 @@
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};
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("}");
}
}
}
}
115 changes: 85 additions & 30 deletions EF4.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,85 @@
import javax.swing.JFrame;
import javax.swing.WindowConstants;

public class EF4 extends JFrame{

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);

}

public String getSuma(String entrada){
String[] numeros = entrada.split(",");
int suma = 0;
//Realizar suma
for(String numero:numeros)
{

}
return suma+"";
}

}
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+"";

}

}