Question: Exercise 4 Write a new programme that will enhance the one you wrote as part of Exercise 6, Tutorial Sheet 4, where you were asked

 Exercise 4 Write a new programme that will enhance the one

Exercise 4 Write a new programme that will enhance the one you wrote as part of Exercise 6, Tutorial Sheet 4, where you were asked to write a method to calculate a Fibonacci number for a given index. Your new programme should take Fibonacci index via user input (e.g. 13) and create an array to accommodate all Fibonacci numbers up to and including the provided index (i.e. 13) as long numbers. Your programme should then declare and implement a method that takes a long array as a parameter, and initialise the array elements by assigning the relevant Fibonacci numbers. After returning the control, you should traverse the array and print all the elements of the array. The output of the programme may look as follows: java FibonacciNumbers04 How long the Fibonacci sequence should be? : 0 1 1 2 3 5 8 13 21 34 55 89 144 13

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!