Object Oriented Programming
Lab 13- Exception Handling Fundamentals, Types of
Exceptions, Using exception clauses
Task 1:
Write a program that Create an exception class named AgeOutOfRangeException
extended from the class Exception. This class should contain a constructor with no
parameter to call the Exception class constructor with the message “You are older than
the requested age (25 years)”.
Task 2:
Create an exception class named NegativeNumberException extended from the class
Exception. This class should contain a parameterless constructor to call the Exception
class constructor with the message “You should enter a positive number”.
Task 3:
Write a program that calculates the average of N integers. The program should prompt the
user to enter the value for N and then afterward must enter all N numbers. If the user
enters a negative value for N, then an exception should be thrown (and caught) with the
message “ N must be positive.” If there is any exception as the user is entering the N
numbers, an error message should be displayed, and the user prompted to enter the
number again.
.
GOOD LUCK