0% found this document useful (0 votes)
8 views1 page

Lab 13 Object Oriented Programming

Uploaded by

ghayoorhassan007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Lab 13 Object Oriented Programming

Uploaded by

ghayoorhassan007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

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

You might also like