Question
The programming environment is PROCESSING from processing.org Q1: Fibonacci In Question 1, you will generate a sequence of Fibonacci numbers. Here is a quick explanation
The programming environment is PROCESSING from processing.org
Q1: Fibonacci
In Question 1, you will generate a sequence of Fibonacci numbers. Here is a quick explanation of the Fibonacci Sequence from Wikipedia:
- In mathematics, the Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and characterized by the fact that every number after the first two is the sum of the two preceding ones.
- The sequence goes: 1 1 2 3 5 8 13 21 34 55 89 144 and so on
- You will make a simple program to print the numbers of the sequence up to the Nth Fibonacci number, with N specified by the user.
- The program will use a for loop. Starting from the first 2 Fibonacci numbers (1 and 1), the loop should calculate the numbers in the sequence until the Nth one is reached. For example, if the user enters 7 for N, then the program should generate the first 7 numbers, stopping at 13.
- At the start of the program you should ask the user to enter the
value of N using JOptionPane.
- The program should prompt the user for a new number if they press any key on the keyboard.
- The program should keep track of the two most recent Fibonacci numbers that it has calculated (you begin with the first two 1s already stored), and use them to calculate the next one. Then the process should repeat.
-
When a Fibonacci number is calculated, the program should draw the number on the screen using global x and y coordinates that are adjusted each time. - There should be 5 columns of numbers per row, as shown in the sample canvas above. A textSize of 20 is adequate.
- Do not worry about numbers being too big past the 30th Fibonacci number.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started