Computer Science, asked by bhavnajain8444, 12 hours ago

Write a function which will return the fraction part after dividing a number by
another. The range should be within 0 and 1. Exception: Since dividing anything by
0 results in error so if the denominator is 0, the function will return 0 instead of
attempting the division.

Answers

Answered by shilpa85475
1

The range should be between 0 and 1.

Exception: Since dividing anything by

0 results in error so if the denominator is 0, the function will return 0 instead of  attempting the division.

Explanation:

class abc

{

  public static void main (String args[])

{

     int num1 = 15, num2 = 0, result = 0;

     try{

         result = num1/num2;

         System.out.println("The result is" +result);

     }  

     catch (ArithmeticException e)

{

        System.out.println ("Can't be divided by Zero " + e);

     }

  }

}

Similar questions