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 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 inputoutput section for the desired inputs and outputs.
points
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
