class UnderageException extends Exception { public UnderageException(String message) { super(message); } } public class VotingEligibility { public static void checkEligibility(int age) throws UnderageException { if (age < 18) { throw new UnderageException("You must be at least 18 years old to vote in the USA."); } else { System.out.println("You are eligible to vote."); } } public static void main(String[] args) { try { checkEligibility(16); // Should throw UnderageException } catch (UnderageException e) { System.out.println("Error: " + e.getMessage()); } try { checkEligibility(20); // Should be eligible } catch (UnderageException e) { System.out.println("Error: " + e.getMessage()); } } }