Fun Exception

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

import javax.swing.

*;
class FunException
{
FunException E;
FunException()
{

}
void disp()
{
JOptionPane.showMessageDialog(null,"Display");
}
static void div() throws NumberFormatException, ArithmeticException
{
int a,b;
a=Integer.parseInt(JOptionPane.showInputDialog(null,"a"));
b=Integer.parseInt(JOptionPane.showInputDialog(null,"b"));
JOptionPane.showMessageDialog(null,"Division : "+(a/b));
}
public static void main(String arg[])
{
FunException E=null;

try
{
div();
}

catch(NumberFormatException e)
{
JOptionPane.showMessageDialog(null,"Please Enter valid
number!!!");
}
catch(ArithmeticException e)
{
JOptionPane.showMessageDialog(null,"Division By 0 Not
Possible !!!");
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,e.toString());
}
finally
{
JOptionPane.showMessageDialog(null,"In Finally Block.");
}
JOptionPane.showMessageDialog(null,"Program Ended");

}
}

You might also like