computer class help

Anonymous
timer Asked: Jan 31st, 2016

Question description

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)

Tutor Answer

(Top Tutor) Studypool Tutor
School: UT Austin
Studypool has helped 1,244,100 students
flag Report DMCA
Similar Questions
Hot Questions
Related Tags

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors