Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need answer in C# 1. Object Oriented programming concepts 2. Interfaces Objective: In this lab you will compute Fibonacci numbers using two different classes, each

Need answer in C#

1. Object Oriented programming concepts 2. Interfaces

Objective:

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(). calculate_fib() should take in an integer, and should return an integer.

Next, create a class FibIteration 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 return 1. Otherwise, youll 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 return the same type as the interface version.

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

Submission Guidelines:

For this assignment youll be submitting 1 interface, the 2 classes, the driver program and a UML diagram in PDF format.

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

Beginning VB 2008 Databases

Authors: Vidya Vrat Agarwal, James Huddleston

1st Edition

1590599470, 978-1590599471

More Books

Students also viewed these Databases questions

Question

Question What are the requirements for a safe harbor 401(k) plan?30

Answered: 1 week ago