Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TareaFinal_201612378 #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
37 changes: 22 additions & 15 deletions EF1.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
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(Factorial(n));

}

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

}
46 changes: 37 additions & 9 deletions EF2.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,37 @@
public class EF2{

public static void main(String args[]){


}


}

public class EF2 {


public static void main(String[] args) {


int[] matriz= {2, 3, 8, 109, 13, 4, 18, 10, 23, 18, 50, 11, 13, 2};
int aux;

System.out.print("{");

for(int i=0;i<matriz.length;i++) {
for(int j=i+1;j<matriz.length;j++) {
if(matriz[i]>matriz[j]) {
aux=matriz[i];
matriz[i]=matriz[j];
matriz[j]=aux;

}

}

if(i<matriz.length-1) {
System.out.print(matriz[i]+", ");
}
else {
System.out.print(matriz[i]);
}

}

System.out.print("}");
}


}
73 changes: 73 additions & 0 deletions EF4.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

public class EF4 extends JFrame implements ActionListener{
JButton sumar;
JTextField ingresar;
JLabel texto;
JLabel resultado;
public static void main(String args[]){

EF4 ventana = new EF4();
ventana.show();
}

public EF4(){
setSize(350, 300);
setTitle("Sumadora");
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setResizable(false);
setLayout(null);

texto = new JLabel();
texto.setText("Ingrese la serie de números separados por coma:");
texto.setBounds(15, 70, 1000, 20);
getContentPane().add(texto);

ingresar = new JTextField();
ingresar.setBounds(45, 120, 250, 20);
getContentPane().add(ingresar);

sumar = new JButton();
sumar.setText("Sumar");
sumar.setBounds(120, 170, 100, 20);
getContentPane().add(sumar);
sumar.addActionListener(this);


resultado = new JLabel();
resultado.setText("");
resultado.setBounds(150, 220, 100, 20);
getContentPane().add(resultado);


}

public String getSuma(){
String entrada = ingresar.getText().trim();
String [] numeros;
numeros = entrada.split(",");
int suma = 0;
for(int i=0; i< numeros.length; i++){

suma =+ suma + Integer.parseInt(numeros[i]);

}

resultado.setText(String.valueOf(suma));
return "";
}

@Override
public void actionPerformed(ActionEvent evento) {

if(evento.getSource()== sumar){

getSuma();
}

}


}