import java.util.Scanner;
class InvalidAgeException extends Exception
{
InvalidAgeException(String msg)
{
super(msg);
}
}
class Voting
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
try
{
System.out.print("Enter age: ");
int age = sc.nextInt();
if(age < 18)
{
throw new InvalidAgeException("Not eligible for voting");
}
System.out.println("Eligible for voting");
}
catch(Exception e)
{
System.out.println("Exception: " + e.getMessage());
}
sc.close();
}
}




