18-Exception Exercise

Опубликовано: 09 Август 2026
на канале: yogiblrithub
56
0

Exercise 1: Division Program with Exception Handling
Objective: Write a Java program that takes two integers as input and divides them. Use try, catch, and finally blocks to handle possible exceptions.

Steps:

Prompt the user to enter two integers.
Divide the first integer by the second.
Handle the following exceptions:
ArithmeticException: If the user tries to divide by zero.
InputMismatchException: If the user enters non-integer values.
Ensure that a message always prints at the end, whether an exception was thrown or not.