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
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
Computer Science,
6 hours ago
Economy,
6 hours ago
English,
12 hours ago
Math,
8 months ago
Math,
8 months ago