Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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.

Turn in your 2 .java classes, SameEnds and SameEndsTester.

Please write like or from my code.

image text in transcribed

image text in transcribed

import java.util.ArrayList; import java.util.Scanner; public class SameEnds Scanner scan new Scanner(System.in); private ArrayList nums) { this.nums nums; public void testEnds() String data for (int i- e; i O: ali.add (ali); ali.add (2); ali.add (3); ali.add (4); ali.add(1) li.add(2); SameEnds typeNumnew SameEnds (ali); typeNum.testEnds ); System.out.print (typeNum)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Real Time Database And Information Systems Research Advances

Authors: Azer Bestavros ,Victor Fay-Wolfe

1st Edition

1461377803, 978-1461377801

More Books

Students also viewed these Databases questions

Question

1.The difference between climate and weather?

Answered: 1 week ago

Question

1. What is Fog ?

Answered: 1 week ago

Question

How water vapour forms ?

Answered: 1 week ago

Question

What is Entrepreneur?

Answered: 1 week ago

Question

Which period is known as the chalolithic age ?

Answered: 1 week ago