import java.io.*;
import java.util.*;
class Numz
{
public static void main(String args[])
{
int i=0,a;
float r;
System.out.println("Enter the number to divide 100:");
Scanner in=new Scanner(System.in);
a=in.nextInt();
try
{
if(a==0)
{System.out.println("Program Terminated Exception Caught");
throw new Exception();
}
if(a!=0)
{
r=100/a;
System.out.println("Result is:"+r);
}
}
catch(Exception e)
{
System.out.println("Exception Caught is Divide By Zero");
}
}
}
import java.util.*;
class Numz
{
public static void main(String args[])
{
int i=0,a;
float r;
System.out.println("Enter the number to divide 100:");
Scanner in=new Scanner(System.in);
a=in.nextInt();
try
{
if(a==0)
{System.out.println("Program Terminated Exception Caught");
throw new Exception();
}
if(a!=0)
{
r=100/a;
System.out.println("Result is:"+r);
}
}
catch(Exception e)
{
System.out.println("Exception Caught is Divide By Zero");
}
}
}
No comments:
Post a Comment