0% found this document useful (0 votes)
9 views

Lab Manual - Lab 13-Exception Handling

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)
9 views

Lab Manual - Lab 13-Exception Handling

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

North South University

Department of Electrical and Computer Engineering


CSE 215L: Programming Language II Lab
Lab – 13: Exception Handling

Objective:
● To understand exception handling and its implementation

Task:
1. Write a program that takes 10 positive integers from user and prints the sum. If any negative
value is entered, the program should catch it as an exception and display “Input positive integer
only”. The program must continue taking input until it gets 10 positive integers.

2. Write a program that creates an integer array of size 100 and initialize it with random values:
int a = (int) (Math.random() * 10000);
The program then takes an integer from user, use it as an index and tries to print the
corresponding element of that array. If index is out of array size, the program should catch it
and display appropriate message.

3. Create a Triangle class. Now create IllegalTriangleException class that extends Exception. If
the sum of any two sides is not greater than the third side, the Triangle class should throw
IllegalTriangleException.

You might also like