Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java program that generates an array of Fibonacci numbers. Specifications: The program -Fills a one-dimensional array with the first 30 Fibonacci numbers using

Write a Java program that generates an array of Fibonacci numbers.

Specifications:

The program

-Fills a one-dimensional array with the first 30 Fibonacci numbers using a calculation to generate the numbers. Note: The first two Fibonacci numbers 0 and 1 should be generated explicitly as in

-long[] series = new long[limit]; //create first 2 series elements series[0] = 0; series[1] = 1;

-But, it is not permissible to fill the array explicitly with the Fibonacci series after the first two elements (0 and 1). From that point on the numbers must be calculated.

-The program prints the first 30 Fibonacci numbers in the array

-Asks the user which of the numbers in this series of 30 he wants to see and prompts for an integer input - a number between 1 and 30 (inclusive). So if the user wants to see the fifth (5th) number of the Fibonacci series the user would input the integer 5 in response to the prompt.

-Checks that the user has not input a number lower than 1 or higher than 30

-Prints in response to the user entry "The nth Fibonacci number is X", where n is the number input by the user and X is the nth Fibonacci number. (Array indexes for the elements of the array start at 0), Example: If user inputs "6" in response to the prompt, the program would print "The 6th Fibonacci number is 5." (without the quotes)

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

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions

Question

Explain the Neolithic age compared to the paleolithic age ?

Answered: 1 week ago

Question

What is loss of bone density and strength as ?

Answered: 1 week ago

Question

What are the Five Phases of SDLC? Explain each briefly.

Answered: 1 week ago

Question

How can Change Control Procedures manage Project Creep?

Answered: 1 week ago