import java.util.*; class Main { public static void main(String args[]) { int x,y,z; System.out.println("Enter x,y values :"); Scanner s=new Scanner (System.in); try { x=s.nextInt(); y=s.nextInt(); z=x/y; System.out.println("Division of two number is : "+z); } catch(ArithmeticException e) { System.out.println("Denominator should not be zero"); } } }
Enter x,y values : 10 2
Division of two number is : 5
Enter x,y values : 10 0
Denominator should not be zero