019-002-005

Exception Class: Age Validation

Hard

Problem Description

In this problem, you will create a program that reads an age value, throws an IllegalArgumentException when the value is less than 0, and displays either the age or an error message to standard output.

Exception class: Age Validation

Learning Objective

Learn different exception classes and when to use them.

Problem

Input age and throw IllegalArgumentException if less than 0.

Input

Line 1: Age (integer)

Output

Normal: Age: [age]
Error: Error: Invalid age.

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up