aca muestro el codigo
espero me puedan colaborar muchas gracias
Cita:
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class Factorial extends Applet implements ActionListener {
Label l1, l2, l3;
TextField t1, t2,t3;
Button b;
public Factorial() {
l1 = new Label("Numero");
t1 = new TextField(3);
l2 = new Label("Factorial");
t2 = new TextField(6);
b = new Button("CALCULAR EL FACTORIAL");
add(l1);
add(t1);
add(l2);
add(t2);
add(b);
b. addActionListener(this);
}
public void actionPerformed(ActionEvent ae) {
double fac=0;
double i;
double numero=Double.parseDouble(t1.getText());
t2.setText("");
for(i=0;i<=fac-1;i++){
fac= fac *(i+1);
}
t2.setText(" " + fac );
}
}
import java.applet.*;
import java.awt.event.*;
public class Factorial extends Applet implements ActionListener {
Label l1, l2, l3;
TextField t1, t2,t3;
Button b;
public Factorial() {
l1 = new Label("Numero");
t1 = new TextField(3);
l2 = new Label("Factorial");
t2 = new TextField(6);
b = new Button("CALCULAR EL FACTORIAL");
add(l1);
add(t1);
add(l2);
add(t2);
add(b);
b. addActionListener(this);
}
public void actionPerformed(ActionEvent ae) {
double fac=0;
double i;
double numero=Double.parseDouble(t1.getText());
t2.setText("");
for(i=0;i<=fac-1;i++){
fac= fac *(i+1);
}
t2.setText(" " + fac );
}
}