Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab submissions-m1 121ABK ITI 1121 Ldborary 5(2019) eGel Homework Help with ChegLX + Not secure l www.site.uottawa.ca/~JY/Courses/IT11121/lectures/labs/lab5-2019.html Abstract classes and interfaces In mathematics, a series

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Lab submissions-m1 121ABK ITI 1121 Ldborary 5(2019) eGel Homework Help with ChegLX + Not secure l www.site.uottawa.ca/~JY/Courses/IT11121/lectures/labs/lab5-2019.html 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. Su 0i 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 Sn. The first call to the method next returns Si, which is the next call to the method next returns S2, which is the next call to the method next returns S3, which is 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. next: double Type here to search 4:16 PM 2/16/2019 Lab submissions-m1 121ABK ITI 1121 Ldborary 5(2019) eGel Homework Help with ChegLX + Not secure l www.site.uottawa.ca/~JY/Courses/IT11121/lectures/labs/lab5-2019.html Arithmetic Geometric Here is a test program that illustrates the intended use of the classes. public class Testseries public static void main(String[] args) AbstractSeries sn double] tuple; snnew Arithmetic); System.out.println("The first five terms of the arithmetic series are:") for (int n-e; n Testseries.java java TestSeries The first five terms of the arithmetic series are 1.8 3.0 6.9 18.e 15.8 The first five terms of the geometric series are 1.e 1.5 1.75 1.875 1.9375 Type here to search 4:16 PM 2/16/2019 Lab submissions-m1 121ABK ITI 1121 Ldborary 5(2019) eGel Homework Help with ChegLX + C Not secure |www.site.uottawa.ca/-gvj/Courses/T1121/lectures/labs/lab5-2019.htm 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 realizes 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. Question 2.3: Arithmetic Implement the class Arithmetic, which is a subclass of AbstractSeries. In this class, the first call to the method next returns the value 1.0, the second call returns the value 3.0, the third call returns 6 the fourth call returns 10 etc. The general formula is as follo s. the it call to the method next returns -+ here . 3 and Si-1 is the value that was returned by the previous call to the method next. Sn 4:17 PM Type here to search 2/16/2019 Lab submissions-m1 121ABK ITI 1121 Ldborary 5(2019) eGel Homework Help with ChegLX + Not secure l www.site.uottawa.ca/~JY/Courses/IT11121/lectures/labs/lab5-2019.html i-1 The first 5 partial sums of the arithmetic series are S2-12 3 Sq-1+2+3-6 S4-1+2+3+4-10 Ss 12+3+4+5-15 Use the provided template as a starting point. | 2.3 Geometric Implement the class Geometric, which is a subclass of AbstractSeries. Each call to the method next produces the next partial sum of the series according to the formula below. The first call returns 1.0, the second call returns 1.5, the third call returns 1.75, etc. You can use Math.pow(a, b), which returns ab, for your implementation. 4:17 PM Type here to search 2/16/2019 Lab submissions-m1 121ABK ITI 1121 Ldborary 5(2019) eGel Homework Help with ChegLX + Not secure l www.site.uottawa.ca/~JY/Courses/IT11121/lectures/labs/lab5-2019.html 2 The first 5 partial sums of the geometric series are: S = 1 +-+-+-+-= 1.9375 2 4 8 16 A call to the method next produces the next partial sum, i.e.the next value of S Use the provided template as a starting point. 4:17 PM Type here to search 2/16/2019 Series.java-Sublime Text (UNREGISTERED) File Edit Selection Find View Goto Tools Project Preferences Help Book.java x Bookcomparator-java l ibrary.java AbstractSenesjava Arithmetic.java xGeometric-java 1 public interface Series // implementation 4. Tab Size: 4 ava 4:17 PM Type here to search 2/16/2019 AbstractSeries.java - Sublime Text (UNREGISTERED) File Edit Selection Find View Goto Tools Project Preferences Help Book.java BookComparatorjava xibray xAbstractseries.java x Arithnetic.java xGeometric-java 1 public abstract class AbstractSeries implements Series public double[] take(int k) f 4. // implement the method Tab Size: 4 4:17 PM Type here to search 2/16/2019 Arithmeticjava Sublime Text( File Edit Selection Find View Goto Tools Project Preferences Help BookComparatorjava xibray 1 public class Arithmetic extends AbstractSeries Book.java AbstractSeriesjava Arithmetic java icjava ktopArithmetic.java // instance variables 4. public double next) /implement the method 9 10 Line 10, Column 2 Tab Size: 4 4:17 PM Type here to search 2/16/2019 Geometricjava Sublime Text( File Edit Selection Find View Goto Tools Project Preferences Help BookComparatorjava xibray 1 public class Geometric extends AbstractSeries Book.java AbstractSeriesjava Arithmetic.java x Geometric-java // instance variables 4. public double next) /implement the method 9 10 Line 10, Column 2 Tab Size: 4 4:17 PM Type here to search 2/16/2019

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

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books

Students also viewed these Databases questions

Question

What is the KPI target value for average sales?

Answered: 1 week ago

Question

What is the purpose of a parameter?

Answered: 1 week ago