Exercise · Exceptions · lesson 12 of 12
Exercise: age check
Write a method static int parseAge(String s) that turns a string into an age. If the string is not a number, or the number is below 0 or above 150, the method throws IllegalArgumentException.
parseAge("30")→30parseAge("-1")→ throwsIllegalArgumentExceptionparseAge("abc")→ throwsIllegalArgumentException
Constraints: 0 and 150 are valid ages; an empty string is not a number.
Do not add extra imports unless the task says so explicitly.