Fibonacci Sequence. You may have learned about Fibonacci Sequences in high school or prior classes. To briefly summarize, it is a sequence that is created when you repeatedly add the two prior numbers in the sequence together. Here is an example of the first few numbers in the sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21… In CSE 1322L, we teach students how to create this sequence using an advanced concept called recursion. In this class however, we’ll use arrays and loops. Your task is to do the following: • Prompt the user to enter the length of the Fibonacci Sequence they want to make ◦ Validate that the number is greater than 0, and keep asking them until it is • Use that number to initialize an empty array ◦ C++ Students: Watch the video posted on the FYE website or D2L to learn how to do this in your language – it’s a little different from the Java and C# approach • Initialize index 0 of the array to 0, and index 1 of the array to 1. • Using a looping structure, fill the array with the correct Fibonacci sequence values • Once the array is full, use another looping structure to print the sequence from the array Note: You must store the sequence in the array, and then print it in a separate loop from the one that created it. You can not print the values in the same loop where you create and store them in the array. Sample Output #1: [Fibonacci Sequence Generator] How long should the Fibonacci Sequence be?: -15 Sequences must be larger than 0! How long should the Fibonacci Sequence be?: 5 Okay, here’s your sequence: 0, 1, 1, 2, 3

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter9: Advanced Array Concepts
Section: Chapter Questions
Problem 4GZ
icon
Related questions
Question

Fibonacci Sequence. You may have learned about Fibonacci
Sequences in high school or prior classes. To briefly summarize, it is a sequence that is
created when you repeatedly add the two prior numbers in the sequence together. Here
is an example of the first few numbers in the sequence:
0, 1, 1, 2, 3, 5, 8, 13, 21…
In CSE 1322L, we teach students how to create this sequence using an advanced
concept called recursion. In this class however, we’ll use arrays and loops.
Your task is to do the following:
• Prompt the user to enter the length of the Fibonacci Sequence they want to make
◦ Validate that the number is greater than 0, and keep asking them until it is
• Use that number to initialize an empty array
◦ C++ Students: Watch the video posted on the FYE website or D2L to learn
how to do this in your language – it’s a little different from the Java and C#
approach
• Initialize index 0 of the array to 0, and index 1 of the array to 1.
• Using a looping structure, fill the array with the correct Fibonacci sequence
values
• Once the array is full, use another looping structure to print the sequence from
the array
Note: You must store the sequence in the array, and then print it in a separate loop from the one
that created it. You can not print the values in the same loop where you create and store them in the
array.
Sample Output #1:
[Fibonacci Sequence Generator]
How long should the Fibonacci Sequence be?: -15
Sequences must be larger than 0!
How long should the Fibonacci Sequence be?: 5
Okay, here’s your sequence:
0, 1, 1, 2, 3

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Program on Numbers
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT