Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.rmi.server.ExportException;
- import java.util.*;
- public class ExceptionHandler {
- // Main Function
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int x = 1;
- do {
- try {
- System.out.print("Enter dividend: ");
- int n1 = input.nextInt();
- System.out.print("Enter divisor: ");
- int n2 = input.nextInt();
- int n = n1 / n2;
- System.out.println(n);
- x = 2;
- }
- catch (Exception e) {
- System.out.println("You can't do that");
- }
- } while (x == 1);
- System.out.println("Finally! You understood that you can't divide by 0");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement