Answer to Question #326954 in Java | JSP | JSF for isaac

Question #326954

Write a program that does the following:


8. a. if (nthFibonacci == 1)

the desired Fibonacci number is the first Fibonacci number.

Copy the value of previous1 into current.

b. else if (nthFibonacci == 2)

the desired Fibonacci number is the second Fibonacci number.

Copy the value of previous2 into current.

c. else calculate the desired Fibonacci number as follows:

Since you already know the first two Fibonacci numbers of the

sequence, start by determining the third Fibonacci number.

i. Initialize counter to 3, to keep track of the calculated

Fibonacci numbers.

ii. Calculate the next Fibonacci number, as follows:

current = previous2 + previous1;

iii. Assign the value of previous2 to previous1.

iv. Assign the value of current to previous2.

v. Increment counter.

9. Append the nth Fibonacci number to outputString. Notice that

the nth Fibonacci number is stored in current.

10. Display the output dialog box showing the first two and the nth Fibonacci

numbers.


0
Service report
It's been a while since this question is posted here. Still, the answer hasn't been got. Consider converting this question to a fully qualified assignment, and we will try to assist. Please click the link below to proceed: Submit order

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS