Question: JAVA homework. Please do not copy code from other answers and please follow the instruction. Thank you! In this lab you will compute Fibonacci numbers

JAVA homework. Please do not copy code from other answers and please follow the instruction.

Thank you!

JAVA homework. Please do not copy code from other answers and please

follow the instruction. Thank you! In this lab you will compute Fibonacci

In this lab you will compute Fibonacci numbers using two different classes, each of which implements the same FindFib interface. Fibonacci is an interesting sequence. The first fibonacci number is 1. The second is 1, every subsequent number is the sum of the previous 2. To put it in math terms: F(n)= F (n-1) + F(n-2). The sequence looks like: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55... Hence Fibonacci(10) is 55. Fibonacci(6) = 8 etc. Assignment Requirements: Begin by creating an interface FindFib. It should have one method calculate_fib(). o calculate_fib() should take in an integer, and should return an integer. Next, create a class FibIteration that implements FindFib. o calculate_fib() should take in the same parameters and return the same type as the interface version. To calculate Fibonacci iteratively you start by checking if you are being asked to calculate the Fibonacci of 1 or 2, if so you return 1. Otherwise, you'll use a loop to keep adding up the previous numbers until you arrive at the answer. Next, create a class FibFormula that implements FindFib. o calculate_fib() should take in the same parameters and return the same type as the interface version. o To calculate Fibonacci by formula, plug in to Binet's Formula: F(n) = (((1+sqrt(5))/2)^n - ((1-sqrt(5))/2)^n) / sqrt(5) Create a driver program which prompts the user to enter a number, then calculate the fibonacci using both methods, and print the results. Create UML diagrams of the interface, 2 classes and driver program. Submit as a PDF along with the code. Sample Output: Enter the number you want to find the Fibonacci Series for: 10 Fib of 10 by iteration is: 55 Fib of 10 by formula is: 55

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!