Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Loops Pgms - Fish The following program is to be written with a loop. You are to

ID: 638647 • Letter: L

Question

Loops Pgms - Fish

The following program is to be written with a loop. You are to write this program THREE times

(3 times) and each time with a different loop control structure (for loop, while loop and do..while).

The Fibonacci numbers Fn are define as follows. F0 is 1, F1 is 1, and Fi+2 = Fi + Fi+1 for i = 0, 1, 2, 3, ... In other words, each number is the sum of the previous two integer numbers. The first few Fibonacci numbers for F2 are 1, 1, 2, 3, 5, and 8. There is also F3 in which you add the last three numbers to form the next F3 number. (Ex 1, 1, 1, 3, 5, 8, 13 etc.) So any Fn is the last n Fib values added to from the next. One place that these numbers occur is as certain population growth rates. If a population has no deaths, then the series shows the size of the population after each time period.

If it takes an organism two time periods to mature to reproducing age, and then the organism reproduces once every time period (thus the reason for two 1's before you start adding). The formula applies most straightforwardly to asexual reproduction at a rate of one offspring per time period. If there are 3 times periods before the next reproduction then start with 3 1

Explanation / Answer

public class MyFibonacci {

    public static void main(String a[]){

         

         int febCount = 15;

         int[] feb = new int[febCount];

         feb[0] = 0;

         feb[1] = 1;

         for(int i=2; i < febCount; i++){

             feb[i] = feb[i-1] + feb[i-2];

         }

         for(int i=0; i< febCount; i++){

                 System.out.print(feb[i] + " ");

         }

    }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote