Question #12117

The first few Fibonacci no. are 1,2,3,5,8.One place that these numbers occur is as certain population growth rates. If a population has no deaths,then the series shows the increase in population growth rates.If a population has no deaths,then the series shows the increase in population after each generation.A generation is the time it takes a member to reach reproducing age.The formula applies most straightforwardly to asexual reproduction at a rate of one offspring per parent per generation. In any event, the green crud population grows at that rate and produces one generation every five days. Hence, if a green crud population starts out as 10 pounds of crud, in 15 days there is 30 pounds, in 20 days there is 50 pounds, and so forth. Create a program that takes as input the initial size of a green crud population (in pounds)and a number of days and then outputs the number of pounds of green crud after that many days.Assume that the popultion size remain the same for four days and then increase on the 5th day

Expert's answer

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace TEMP

{

class Program

{

& static void Main(string[] args)

& {

int n = 0;

int crud = 0;

Console.Write("Initial size(in pounds): ");

crud = int.Parse(Console.ReadLine());

Console.Write("Number of days: ");

n = int.Parse(Console.ReadLine());

int previous = crud;

n -= 5;

while (n >= 5)

{

int temp = crud;

crud = crud + previous;

previous = temp;

n -= 5;

}

Console.WriteLine("Population size is " + crud.ToString() + " pounds.");

Console.ReadLine();

& }

}

}

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace TEMP

{

class Program

{

& static void Main(string[] args)

& {

int n = 0;

int crud = 0;

Console.Write("Initial size(in pounds): ");

crud = int.Parse(Console.ReadLine());

Console.Write("Number of days: ");

n = int.Parse(Console.ReadLine());

int previous = crud;

n -= 5;

while (n >= 5)

{

int temp = crud;

crud = crud + previous;

previous = temp;

n -= 5;

}

Console.WriteLine("Population size is " + crud.ToString() + " pounds.");

Console.ReadLine();

& }

}

}

Learn more about our help with Assignments: C#

## Comments

## Leave a comment