Exception Handling - Finally block
VTA Technologies is planning to conduct a Walk-in interview. The interview has 4 levels. To attend the interview, the candidates need to register the following information:
Name, Age, Expected salary and Gender. The age limit for the candidates is between 18 and 50.
Develop a console application to implement the above given scenario.
Use exception handling to validate age and salary of the candidate. If the candidate’s age is less than 18 or greater than 50 throw a user defined exception as AgeException and display the message “Registration Failed. Age should be greater than 18 and less than 50". If candidate’s age is between 18 and 50, then get the other information (Salary and Gender).
Likewise, if the candidate’s expected salary is less than or equal to 0 throw a user defined exception as SalaryException, then display the message as “Registration Failed. Salary cannot be a negative number”. If the salary is not a negative number, then get the Gender details and display the message as “Registration Successful”. Irrespective of whether the registration is successful or not, print the message “Best Wishes”.
Sample Input/output Statements:
Enter the Name:Rahul
Enter the Age:35
Enter the Salary:25000
Enter the Gender(f/m):m
Rahul
35
m
Registration Successful
Best Wishes
Sample Input/output Statements:
Enter the Name:Rahul
Enter the Age:15
Registration Failed. Age should be greater than 18 and less than 50
Best Wishes