.Write a java program to divide any two numbers using the try and catch block. please help fast
Answers
In this java program, we are reading two integer numbers and dividing them also checking the exception. Program will through an error if second number (divisor) will be zero (0).Given two integer numbers and we have to divide them by checking exception if divisor is 0.Example:
In this java program, we are reading two integer numbers and dividing them also checking the exception. Program will through an error if second number (divisor) will be zero (0).Given two integer numbers and we have to divide them by checking exception if divisor is 0.Example:Input: Enter first number : 70 Enter second number : 5 Output: Result:14 Explanation: There is no exception because divisor is not 0 Input: Enter first number : 100 Enter second number : 0 Output: Error:/ by zero Explanation: Error:java.lang.ArithmeticException: / by zero
Answer:
java
public class Exercise3 {
public static void main(String[] args) {
System.out.println(50/3);
}
}