import java.util.*;
class CatchBlock
{
public static void main(String args[])
{
try
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter Two Number : ");
System.out.print(" First Number : ");
int n1 = sc.nextInt();
System.out.print(" Second Number : ");
int n2 = sc.nextInt();
int div = n1 / n2;
System.out.println(" Result is = "+div);
}
catch(ArithmeticException e)
{
System.out.println(" Second Number is 0 [zero] then divide is not possible.");
}
}
}
INPUT
Enter Two Number :
First Number : 10
Second Number : 0
OUTPUT
Second Number is 0 [zero] then divide is not possible.
Copyright ©
All Notes on BCA