import java.awt.event.*; //Fakultaet berechnen mit grafischer Oberflaeche
import java.awt.*;
public class a47 extends Panel implements ActionListener{
	Button b= new Button("Fakultaet berechnen");
	double Zahl;
	TextField eingabe=new TextField(10);
	Label ausgabe=new Label("Geben Sie eine ganze Zahl ein und berechnen Sie die Fakultaet");
	public a47(){
		add(eingabe);
		add(b);
		b.addActionListener(this);
		add(ausgabe);
	}
	public void actionPerformed(ActionEvent e){
		double Zahl=(double)Integer.parseInt(eingabe.getText());
		ausgabe.setText("Die Fakultaet von "+Zahl+" ist "+fakultaet(Zahl));
	}
	public static void main(String args[]){
		Frame Fenster = new Frame("Aufgabe 47");
		Fenster.add("Center", new a47());
		Fenster.addWindowListener(new WindowAdapter(){
			public void windowClosing(WindowEvent e){System.exit(0);}});
		Fenster.pack();
		Fenster.setSize(400,300);
		Fenster.setVisible(true);
	}
	static double fakultaet (double zahl){
		if (zahl>0){
			if (zahl<=1) return 1.0;
		    else return zahl*fakultaet(zahl-1);
		}
		else return 0.0;
	}
} //:-)