Question: 1. Write a Java class called SeismicAnalysis in a class file called SeismicAnalysis.java. 2. The SeismicAnalysis class contains a single attribute; an ArrayList of type

1. Write a Java class called SeismicAnalysis in a class file called SeismicAnalysis.java. 2. The SeismicAnalysis class contains a single attribute; an ArrayList of type Double named measurements. 3. Write the following methods as members of the SeismicAnalysis class:

a. A lone constructor that takes one argument, a String called filename. The constructor opens and reads from the binary data file (NOT a text file) specified by filename storing the results in the measurements attribute. If the file does not exist or is corrupted, then the method throws the AnalysisException (see below); this is done by first catching the IOException and then throwing the AnalysisException. b. A public method called countAbove(). This method takes one argument, a double value called threshold. This method returns an int value for the number of elements in measurements that exceed the value of threshold. It performs this by calling a private helper method (which you also need to define) that uses head recursion to traverse the values of the measurements attribute. c. A public method called countBelow(). This method takes one argument, a double value called threshold. This method returns an int value for the number of elements in measurements that are less than the value of threshold. It performs this by calling a private helper method (which you also need to define) that uses tail recursion to traverse the values of the measurements attribute. 4. To make sure that your implementation is working correctly, you need to create an AnalysisException class as an extension of a RuntimeException. This exception needs to be thrown if a problem occurs when reading data from a file. Create a file called AnalysisException.java containing the following code: public class AnalysisException extends RuntimeException {

public AnalysisException(String s) {

super(s);

}

}

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 Databases Questions!