A numeric progression is a sequence of numbers where each


Please answer this question in java

a) Inheritance

A numeric progression is a sequence of numbers, where each number depends on one or more of previous numbers.

Design and implement two classes that define arithmetic and geometric progression.

Start by defining a parent class called Progression. This class should contain the following instance variables :

• first - first value of the progression

• cur - current value of the progression

Both variables should be initialized with values passed into the constructor .

Progression should also have three methods:

• firstValue() - Reset the progression to the first value, and return that value .

• nextValue() -Step the progression to the next value and return that value.

• printProgression(n) - Reset the progression and print the first n values of progression.

Two classes should inherit from Progression:

ArithProgression that defines and prints out an arithmetic progression, where the next value is determined by adding a fixed increment to the previous value. Set the default increment to 1 in the default constructor. Provide setinc() method to set the increment value.

GeomProgression that steps and prints out a geometric progression, where the next value is determined by multiplying the previous value by a fixed base. Set the default base to 2 in the default constructor. Provide setbase() method to set the base value.

Test the classes in a Driver class . In the Driver class ,

Print out the 10 Arithmetic progression with default increment and increment by 5 using constructor. Use setinc method to set increment by 10 and print out 10 Arithmetic progression also.

Print out the 10 Geometric progression with default base, base equal to 3 by using constructor. Use setbase method to set base equal to 5 and print out 10 Geometric progression also.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: A numeric progression is a sequence of numbers where each
Reference No:- TGS02887462

Expected delivery within 24 Hours