Write a program to accept name and age of a person from the command prompt(passed as arguments when you execute the class) and ensure that the age entered is >=18 and < 60. Display proper error messages. The program must exit gracefully after displaying the error message in case the arguments passed are not proper. (Hint : Create a user defined exception class for handling errors.)
Write a program to accept name and age of a person from the command prompt(passed as arguments when you execute the class) and ensure that the age entered is >=18 and < 60. Display proper error messages. The program must exit gracefully after displaying the error message in case the arguments passed are not proper. (Hint : Create a user defined exception class for handling errors.) //If you have any alternate method then comment below. public class ExceptionHandling5 { public static void main(String[] args) { String name = args[0]; int age = Integer.parseInt(args[1]); try { if(age < 18 || age >= 60) throw new InvalidAgeException("Invalid Age"); System.out.println("Name: "+name+" Age: "+age); } catch (InvalidAgeException e) { System.out.println(e); } } } class InvalidAgeException extends Exception { public InvalidAgeException(String age) { super(age); } } Write a Program to tak...