package sum;
import javax.swing.JOptionPane;
public class implementtryandcatch {
public static void main(String[] args) {
int a,b,c=0;
try
{
a=Integer.parseInt(JOptionPane.showInputDialog("enter A:"));
b=Integer.parseInt(JOptionPane.showInputDialog("enter B:"));
c=a/b;
}
catch (Exception p)
{
System.out.print(p.getMessage());
}
System.out.print("\ndivision="+c);
}
}
import javax.swing.JOptionPane;
public class implementtryandcatch {
public static void main(String[] args) {
int a,b,c=0;
try
{
a=Integer.parseInt(JOptionPane.showInputDialog("enter A:"));
b=Integer.parseInt(JOptionPane.showInputDialog("enter B:"));
c=a/b;
}
catch (Exception p)
{
System.out.print(p.getMessage());
}
System.out.print("\ndivision="+c);
}
}
output:
enter A 5
enter B 0
/ by zero
division=0
No comments:
Post a Comment
SAY HELLO!!