Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is java and please must follow the instruction and must put //(comment) and make simple program. Thank you Problem 3: Calculating Fibonacci numbers. The

This is java and please must follow the instruction and must put //(comment) and make simple program. Thank you

Problem 3: Calculating Fibonacci numbers. The Fibonacci series is famous mathematical and computer science algorithm. For one thing it can describe the growth of a rabbit population.

a) Create a class named Fib

b) Create an instance variable named number

c) Create a constructor that has an argument which is an integer and hold the number your wish to calculate the Fibonacci series for.

d) Assign the argument to number.

e) Create a method named calcFib. It will not have an argument.

f) Create three integer local variables named fold1, fold2, and foldNew. Set foldNew to 0. Set fold1 and fold2 to 1.

g) Create a for loop that runs from 0 to less than number

h) Set for foldNew to fold1 plus fold2.

i) Set fold2 to fold1;

j) Set fold1 to foldNew;

k) At the end of the loop return foldNew

l) Create a class called FibTester (this should only have a main method)

m) Import Scanner

n) Create a Scanner object

o) Prompt the user for the number for which they want to calculate the Fibonnacci value.

p) Get and integer and assign it to num.

q) Create a Fib object using num as the argument.

r) Call calcFib and print the result. (This can be done in one or two steps)

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

Build It For The Real World A Database Workbook

Authors: Wilson, Susan, Hoferek, Mary J.

1st Edition

0073197599, 9780073197593

More Books

Students also viewed these Databases questions

Question

What changes led to the evolution of performers' unions?

Answered: 1 week ago