Question: Write a Java program to create your own Exception class named DuplicateException. This exception class throws an error if an array chatains duplicate elements. Write

Write a Java program to create your own Exception class named DuplicateException. This exception class throws an error if an array chatains duplicate elements. Write a program in Java that reads 5 elements from console to initialize the array and pass the array in a method named findSum (). If the array contains any duplicate elements, the findSum () method throws the DuplicateException. Otherwise, the method calculates the sum of five elements and prints the result. See the sample input/output section for the desired inputs and outputs.
(15 points)
Write a Java program to create your own Exception

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!