Documentos de Académico
Documentos de Profesional
Documentos de Cultura
class Transporte {
}
}
Guis
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public AplicationGUIs() {
lb1 = new JLabel("Ingrese un numero: ");
lb2 = new JLabel("Resultado: ");
btn_ver = new JButton("Calcular");
btn_sal = new JButton("Cerrar");
jfr.setVisible(true);
jfr.setBounds(350, 150, 450, 200);
jpn.setLayout(null);
jfr.add(jpn);
btn_ver.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
int n;
String nu;
int mod;
nu = jt.getText();
n = Integer.parseInt(nu);
mod = Fact(n);
lb2.setText("El factorial de !" + nu + " es igual a: "
+ mod);
}
});
btn_sal.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
System.exit(0);
}
});
if (n == 0 || n == 1) {
return 1;
} else {
return (n * Fact(n - 1));
}
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public AplicationGUIs(){
lb1 = new JLabel("Ingrese un numero: ");
lb2 = new JLabel("Resultado: ");
btn_ver = new JButton("Verificar");
btn_sal = new JButton("Salir");
jfr.setVisible(true);
jfr.setBounds(350,150,450,200);
jpn.setLayout(null);
jfr.add(jpn);
btn_ver.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0){
int n;
String nu;
boolean mod;
nu=jt.getText();
n=Integer.parseInt(nu);
mod=verificar(n);
if(mod == true){
lb2.setText("Es primo");
}
else{
lb2.setText("No es primo");
}
}
});
btn_sal.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0){
System.exit(0);
}
});
while(i<n){
if(n%i == 0){
mod=false;
break;
}
i++;
}
System.out.println("verificado");
return mod;
}
public static void main(String[] args) {
// TODO code application logic here
AplicationGUIs num = new AplicationGUIs();
}
}
ABSTRACCION
protected int x;
protected int y;
private int r;
private int r;
private int h;
System.out.println("Circulo");
System.out.println("Area: " + cir.area());
System.out.println("Volumen: " + cir.volumen());
System.out.println("");
System.out.println("Cilindro");
System.out.println("Area: " + cil.area());
System.out.println("Volumen: " + cil.volumen());
}
JERARQUIA
class Transporte {
//caso 1
public String getNombre() {
return nombre;
}
//Caso 2
public String getDatos() {
return (nombre + "\t" + color + "\t" + marca + "\t" + precio);
}
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.println(av.verDatos() + "\n");
System.out.println(au.verDatos() + "\n");
}
}
RECURSIVIDAD
import java.util.Scanner;
if (n < 10) {
return cont;
} else {
return (cont + Contar(n / 10));
}
}
n = key.nextInt();
package constructor;
class Paralelepipedo {
private int a;
private int b;
private int c;
import java.util.Scanner;
System.out.println("Aux: "+aux);
System.out.println("potencia: "+potencia);
System.out.println("Sum: "+sum);
System.out.println("Dato: "+dato);
System.out.println(" ");
}
}
}
import java.util.Scanner;
POO
class Pares {
private static int dato;
while(aux != 0) {
aux2 = aux/10;
if (aux2 % 2 == 0) {
cont++;
}
aux = aux2;
}
return cont;
}
}
par.setDato(123456);