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
40 changes: 27 additions & 13 deletions EF1.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
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
package EF1;

}
}
}
import java.util.Scanner;

/**
*
* @author Zelda
*/
public class EF1 {
public static int n;
public static void main(String[] args) {
int n= Integer.parseInt(args[0]);
System.out.println(Factorial(n));

}
public static int Factorial(int n){
if (n==0){
return 1;
}
else {
return n * Factorial(n-1);
}
}
}




47 changes: 39 additions & 8 deletions EF2.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,40 @@
public class EF2{

public static void main(String args[]){


}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package EF2;

public class EF2 {

public static void main(String[] args){
int array[] = {2,3,8,109,13,4,18,10,10,23,18,50,11,13,2};
EF2 bs= new EF2();
bs.sort(array);
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]){
int temp=array[j];
array[j]=array[j-1];
array[j-1]=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("}");
}
}
}

}


}
74 changes: 74 additions & 0 deletions EF4.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@

package EF4;
import java.awt.Container;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
/**
*
* @author Zelda
*/
public class EF4 extends JFrame {
private JButton jsumar;
private JTextField numero;
private JLabel resultado;
private JPanel caja;

public static void main(String[] args) {
EF4 ventana = new EF4();
ventana.show();
}

public EF4(){
setSize(250, 300);
setTitle("Calculadora");
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setResizable(false);
}

public String getSuma(String entrada){
Container contenedor = getContentPane();

numero = new JTextField("Ingresar números separados por comas");
numero.setBounds(30, 30, 200, 30);

jsumar = new JButton("Sumar");
jsumar.setBounds(50,50,100,20);
jsumar.addActionListener((ActionEvent e) -> {
String ingresar = numero.getText();
resultado.setText(getSuma(entrada));
});

resultado = new JLabel();
resultado.setBounds(100,100,100,100);

caja= new JPanel();
caja.setLayout(null);
caja.add(numero);
caja.add(jsumar);
caja.add(resultado);
contenedor.add(caja);

public String getSuma(String entrada){
String[] numeros = entrada.split(",");
int suma = 0;
int suma1 = 0;
//Realizar suma
for(String numero:numeros)
{
int N = Integer.parseInt(numero);
suma = suma1 + N;
suma1 = suma;
}
return suma+"";



}
}