1. Engineering
  2. Computer Science
  3. write java a class named sameends write a sameendstester to...

Question: write java a class named sameends write a sameendstester to...

Question details

Write JAVA a class named SameEnds. Write a SameEndsTester to test your class. SameEnds determines whether an array list has the same sequence of numbers at the left and at the end, and if so, how long that sequence is. You will not prompt the user for data. Enter your test data via a SameEnds constructor from SameEndsTester. You may assume that all of the elements in the array list are integers.

For example, the array list 1 4 9 10 11 12 1 4 9 has the same sequence 1 4 9 at the left and the right, and it has length 3. Therefore, your SameEndsTester would print out “The longest sequence is 1 4 9, and the sequence length is 3”.

If the arraylist doesn't have a common sequence at the left and the right, such as 1 4 9 16 25 SameEndsTester should print out “There are no common sequences”. The two sequences cannot overlap.

For example, in the array 1 1 1 1 the sequence 1 1 occurs at the left and the right, and your method should return “The longest sequence is 1 1, and the sequence length is 2”.

Here is link of google docs for easier reading.

https://docs.google.com/document/d/196RKXFVSmRrEF5BvCj4QpzGhFcYRGOj7M2dsSE_59KU/edit

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution