import java.util.*;
public class Pgm2
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int a=0,b=0;
try
{
System.out.print("Enter a Number 1: ");
a = in.nextInt();
System.out.print("Enter a Number 2: ");
b = in.nextInt();
}
catch(NumberFormatException e)
{
System.out.println("You Caught Error in Input and Output");
}
try
{
int sum=a/b;
System.out.println("The Answer="+sum);
}
catch(ArithmeticException e)
{
System.out.println("You cannot divide any number by zero");
}
finally
{
System.out.println("Reached End of Program");
}
}
}
0 Comments