import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.text.DecimalFormat;
import sifiraBolunmeException;

public class sifirabolmetesti1 extends Applet implements ActionListener
{
protected Label L1,L2;
protected TextField T1,T2;
private int sayi1,sayi2;
private double sonuc;

public void init()
{
sayi1=0;
sayi2=1;
L1=new Label("Payi gir : ");
L2=new Label("Paydayi gir : ");
T1=new TextField(10);
T2=new TextField(10);
T2.addActionListener(this);
add(L1);
add(T1);
add(L2);
add(T2);
}

public double bol(int s1,int s2) throws ArithmeticException
{
if(s2==0) throw new ArithmeticException("sifira bolmeye calistiniz");
return (double) s1/s2;
}

public void actionPerformed(ActionEvent e)
{
DecimalFormat hassaslik3=new DecimalFormat("#.000");

try{
sayi1=Integer.parseInt(T1.getText());
sayi2=Integer.parseInt(T2.getText());
T1.setText("");
T2.setText("");
sonuc=bol(sayi1,sayi2);
showStatus(sayi1+" / "+sayi2+" = "+hassaslik3.format(sonuc));
}
catch(NumberFormatException nfe)
   {showStatus("iki tam sayi girmelisiniz.");}
catch(ArithmeticException sbh)
   {showStatus(sbh.toString());}
}

}
