Question: Java - Arrays -Create a class called Sequence that stores a sequence of double values, as follows (complete missing code): public class Sequence{ //instance variables

Java - Arrays -Create a class called Sequence that stores a sequence of double values, as follows (complete missing code): public class Sequence{ //instance variables private double[] values; //constructors public Sequence(int size) {.} //methods public void set(int i, double value) {.} public double get(int i) {.} public int size(){.} public double highest() {.} }//class Add the following constructors and methods: - public Sequence(double []array) {..} Constructs a sequence object from a double array parameter. Use Arrays.copyOf() to create a copy of the array parameter. - public Sequence(Sequence s) {.} Constructs a sequence object from another Sequence object s received as a parameter. Use Arrays.copyOf() to create a copy of the values array of the Sequence object parameter. - Add a method: public String toString() that returns a string representation of the sequence array values. - Add a method: public double[] toArray() that returns an array copy of the sequence array values. - Add a method: public boolean equals(Sequence other)that checks whether the two sequences have the same values in the same order. Provide Sequence Tester class that constructs four Sequence objects, as follows: - sequence1 object: constructed using a size value read from the user. Its data are read from the user (See the sample run). - sequence2 object: constructed using the array double[] secondSeqData={10,20,30,80,50}; - sequence3 object: constructed using sequence1 object - sequence4 object: constructed using the array version of sequence2 object. - Display the report shown in the sample run about each sequence object information. The following gives two sample runs of a Sequence Tester class: Part2 Sample Run: run: Enter sequence1 size >0? 6 Enter 6 double values for sequence1 data:23 45 67 90 10 80 Sequence1 values:23.0, 45.0, 67.0, 90.0, 10.0, 80.0 Sequence1 size:6 Sequence1 highest value:90.0 Sequence2 values:10.0, 20.0, 30.0, 80.0, 50.0 Sequence2 size:5 Sequence2 highest value:80.0 Sequence1 does not equal Sequence2. Sequence3 values:23.0, 45.0, 67.0, 90.0, 10.0, 80.0 Sequence3 size:6 Sequence3 highest value:90.0 Sequence3 equals Sequence1. Sequence4 values:10.0, 20.0, 30.0, 80.0, 50.0 Sequence4 size:5 Sequence4 highest value:80.0 Sequence4 equals Sequence2. BUILD SUCCESSFUL (total time: 26 seconds)

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!