class MyException extends Exception{
}
class voting{
public static void isEligible(int age) throws MyException{
if(age<19)
throw new MyException();
else
System.out.println("can caste vote");
}
}
class MyTest{
public static void main(String args[]){
try{
int age=Integer.parseInt(args[0]);
voting.isEligible(age);
}
catch(MyException e){
e.printStackTrace();
System.out.println("Invalid Age can't vote");
}
catch(NumberFormatException e){
e.printStackTrace();
System.out.println("please supply age must be digits");
}
catch(Exception e){
e.getMessage();
}
}
}