Question: Write a method that will perform a simple division of two integers. Use try block ( s ) that will request two integers from your
Write a method that will perform a simple division of two integers. Use try blocks that will request two integers from your user and divide the first by the second and assign to a third integer variable. Create a catch block that catches the InputMismatchException generated by nextInt when reading the user input as an integer. Create a second trycatch block that catches the ArithmeticException that is generated when the divisor is When the second number entered "throw" an exception, the user only reenters the second number does not need to enter the first number again.
Embed the catch blocks in an error trap to ensure a correct division result. Make sure your program can handle the ArithmeticException also avoid integer division. Write a statement after the error trap to display the result. name this method startup
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
