Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please do this in Java, the templates are as follows: public interface Series { // implementation } public abstract class AbstractSeries implements Series { public

image text in transcribedimage text in transcribed Please do this in Java, the templates are as follows: public interface Series { // implementation } 
public abstract class AbstractSeries implements Series { public double[] take(int k) { // implement the method } }
Abstract classes and interfaces In mathematics, a series is an infinite sequence of terms added together. The partial sum of the series, Sn is the sum of the first n terms. Here, you must create a class hierarchy, as illustrated by the UML diagram below, such that all the series have a method next, which returns the next S. The first call to the method next returns Si, which is the next call to the method next returns S, which is the next call to the method next returns S3, which is 2. + y + and so on. The implementation of the method next is specific to the type of series, here Arithmetic and Geometric. Specifically, this hierarchy consists of the interface Series, an abstract class called AbstractSeries, as well as two concrete implementations, called Arithmetic and Geometric. Here is a test program that illustrates the intended use of the classes: for the partial sum of an Arithmetic Series with 1 as the first term and 1 as common difference; for the partial sum of a Geometric Series with 1 as the first term and 0.5 as common ration public class Test Series public static void main(String[] args) { Abstract Series on: doubler) tuple sn = new Arithmetic(); System.out.println("The first five turn of the arithmetic series are:" ); for (int n ; n TestSeries. Java > Java Test Series The first five terms of the arithmetic series are: 10.0 The first five terms of the geometric series are: 1.75 1.875 1.9375 The first loop displays the values 1.0, 3.0, 6.0, 10.0, 15.0, whilst the second one displays, 1.0, 1.5, 1.75, 1.875, 1.9375. Question 2.1: Series Create an interface called Series. It declares a method called next that has a return-type double. Use the provided template as a starting point. Question 2.2: AbstractSeries Write the implementation of the abstract class AbstractSeries. It implements the interface Series. The class implements a method called take that returns an array containing the next k partial sums of this series, where k is the formal parameter of the method take. Use the provided template as a starting point

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

Database Systems A Practical Approach To Design Implementation And Management

Authors: THOMAS CONNOLLY

6th Edition

9353438918, 978-9353438913

More Books

Students also viewed these Databases questions

Question

What steps will Sara need to take to conduct a benefit audit?

Answered: 1 week ago