I'm unable to catch the InputMismatchException even though I imported java.util.InputMismatchException
;
At line 2 :: The import java.util.InputMismatchException cannot be resolvedJava(268435846)
At line 19 :: InputMismatchException cannot be resolved to a typeJava(16777218)
I'm currently using VScode editor
package LabPrograms;
import java.util.InputMismatchException;
import java.util.Scanner;
public class Lab11 {
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int n,d,res;
try{
System.out.println("Enter two digits: ");
n=sc.nextInt();
d=sc.nextInt();
res=n/d;
System.out.println(res);
}
catch(ArithmeticException ea)
{
System.out.println("Divide by zero error: "+ea);
}
catch(InputMismatchException ei)
{
System.out.println("Invalid input entered: "+ei);
}
}
}