Question: Problem: The Fibonacci class Your output should look like this: Specifications: In addition to the main method, you need two methods to do this. fibonacciIterative:

Problem: The Fibonacci class

Your output should look like this:

Problem: The Fibonacci class Your output should look like this: Specifications: In

addition to the main method, you need two methods to do this.

Specifications:

In addition to the main method, you need two methods to do this.

fibonacciIterative: which calculates the Fibonacci numbers using iterations

fibonacciRecursive: which calculates the Fibonacci numbers using recursions.

main Method

a) The main method should first create a Scanner object.

b) It will then read in from users input an integer number num, indicating how many Fibonacci numbers in the sequence the program is expected to compute and output. For example, if the user input 6, it means the program is expecting the first 6 numbers in the Fibonacci sequence.

c) The main method will introduce a loop and calls the fibonacciIteraive method to achieve each of these num numbers, and output them. Please output all these numbers in one line, separated by a space.

d) The main method then will also introduce a loop and calls the fibonacciRecursive method to achieve each of these num numbers and output them. Please output all these numbers in one line, separated by a space.

e) Iterations and recursions should generate the same sequence of numbers

I'm kinda stuck on the fibonacciIterative Method. some comments on this would help alot

fibonacciIterative Method

You can figure out your own way to calculate this Fibonacci number or follow the following pseudocodes.

previous = 0

last =1

next =1

repeat n times

previous = last

last = next

next = last + previous

return previous

fibonacciRecursive Method

The definition of Fibonacci numbers is internally recursive. Please follow the formula as mentioned above, and use recursions to compute a specific number in the Fibonacci sequence.

The same as the fibonacciIteraive method, the fibonacciRecursive also accepts one parameter (suppose it is n), which indicates the (n+1)-th

Please enter a number: 10 The first 10 numbers in Fibonacci sequence using iteration: 0112 3 5 8 13 21 34 The first 10 numbers in Fibonacci sequence using recursion: 0112 3 5 8 13 21 34 Please enter a number: 10 The first 10 numbers in Fibonacci sequence using iteration: 0112 3 5 8 13 21 34 The first 10 numbers in Fibonacci sequence using recursion: 0112 3 5 8 13 21 34

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!