Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please answer in java Concept Summary: 1. Object Oriented programming concepts 2. Interfaces Objective: In this lab you will compute Fibonacci numbers using two different

please answer in java
image text in transcribed
Concept Summary: 1. Object Oriented programming concepts 2. Interfaces Objective: In this lab you will compute Fibonacci numbers using two different classes, cach of which implements the same FindFib interface Fibonacci is an interesting sequence. The first fibonacci number is I. The second is I every subsequent number is the sum of the previous 2. To put it in math terms: Fn)-F(n-1) +Fin - 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(): calculate_fib() should take in an integer, and should return an integer Next, create a class Fiblteration that implements FindFib. 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 retur I. 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. calculate_fib() should take in the same parameters and retum the same type as the interface version To calculate Fibonacci by formula, plug in to Binet's Formula: . F(n) =((CI+sqrt(5)y2)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 Fab of 10 by formula is: 55

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions