Data Structures and Algorithms in Java
Data Structures and Algorithms in Java
6th Edition
ISBN: 9781118771334
Author: Michael T. Goodrich
Publisher: WILEY
Question
Book Icon
Chapter 2, Problem 23C
Program Plan Intro

Fibonacci series

Program plan:

  • Create a main class Progression that prints out the Fibonacci series.
    • In main() function,
      • Create the object for Progression class.
      • Using the object, it prints the value of Fibonacci series starting with 0.
      • Declare the default constructor with no parameter.
      • Define the parameterized constructor to start the Fibonacci series.
      • Define a method nextValue() to return the next value of the progression.
      • Define a method advance() that advances the current value to the next value of the progression.
      • Finally print the values of progression with spaces using printProgression() method.
    • In the FibonacciProgression class,
      • Derive the FibonacciProgression class from Progression class.
      • Create a default constructor to build up the traditional Fibonacci.
      • Define a parameterized constructor to construct a generalized Fibonacci, with the first and second values
      • Create a method advance() to replace previous and current values.

Blurred answer
Students have asked these similar questions
Why is it important for a class to have a destructor implemented? With your comment, fill in the spaces.
How can you prevent the derived class from accessing methods from the base class?
Java-  Suppose that Vehicle is a class and Car is a new class that extends Vehicle. Write a description of which kind of assignments are permitted between Car and Vehicle variables.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
  • Text book image
    Microsoft Visual C#
    Computer Science
    ISBN:9781337102100
    Author:Joyce, Farrell.
    Publisher:Cengage Learning,
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,