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

public class sifirebolmetesti extends Applet implements ActionListener
{
private Label L1,L2;
private 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 sifiraBolunmeException
  {
   if(s2==0) throw new sifiraBolunmeException();
   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(sifiraBolunmeException sbh)
        {showStatus(sbh.toString());}
     }
  }


