Question: Give a short fragment of Java code that uses the progression classes from Section 2.2.3 to find the eighth value of a Fibonacci progression that

Give a short fragment of Java code that uses the progression classes from Section 2.2.3 to find the eighth value of a Fibonacci progression that starts with 2 and 2 as its first two values

Code and explain how it works. If you copy and paste from the pictures I attach I will report you

Give a short fragment of Java code that uses the progression classes

2

from Section 2.2.3 to find the eighth value of a Fibonacci progression

public class FibonacciProgression extends Progression \{ protected long prev; / Constructs traditional Fibonacci, starting 0,1,1,2,3,/ public FibonacciProgression( ) { this (0,1);} / Constructs generalized Fibonacci, with give first and second values. * / public FibonacciProgression(long first, long second) \{ super(first); prev = second - first; // fictitious value preceding the first \} protected void advance( ) \{ long temp = prev; prev = current; current += temp; \} (current, current+prev). */ /** Test program for the progression hierarchy. */ public class TestProgression \{ public static void main(String[] args) Progression prog; // test ArithmeticProgression System.out.print("Arithmetic progression with default increment: " "); prog = new ArithmeticProgression(); prog.printProgression(10); System.out.print("Arithmetic progression with increment 5 : "); prog = new ArithmeticProgression(5); prog.printProgression(10); System.out.print("Arithmetic progression with start 2 : "); prog = new ArithmeticProgression(5, 2); prog.printProgression(10); // test GeometricProgression System.out.print("Geometric progression with default base: "); prog = new GeometricProgression( ); prog.printProgression(10); System.out.print("Geometric progression with base 3 : "); prog = new GeometricProgression(3); prog.printProgression(10); // test FibonacciProgression System.out.print("Fibonacci progression with default start values: "); prog = new FibonacciProgression(); prog.printProgression(10); System.out.print("Fibonacci progression with start values 4 and 6: "); prog = new FibonacciProgression(4, 6); prog.printProgression(8); \}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!