EXPERIMENT-7
PROBLEM7.1:-
Create an array with ve elements. Write a program that prompts the user to
enter an index and then prints the corresponding array element. Handle the
ArrayIndexOutOfBoundsExcep on" if the entered index is invalid.
SOLUTION:-
OUTPUT:-
fi
ti
PROBLEM7.2:-
Write a program that performs arithme c opera ons. If an
"Arithme cExcep on" occurs (e.g., division by zero), provide an op on to
retry the opera on.
SOLUTION:-
OUTPUT:-
ti
ti
ti
ti
ti
ti
PROBLEM7.3:-
Demonstrate the use of throw and throws using an example
SOLUTION:-
OUTPUT:-
PROBLEM7.4:-
Create a program represen ng a simple banking system. De ne a custom
excep on "Insu cientFundsExcep on" and throw it if a user a empts to
withdraw more money than their account balance.
SOLUTION:-
OUTPUT:-
ti
ffi
ti
ti
fi
tt