The program is similar to the fibonnaci numbers. Here's the entire problem:
One place the fibonnaci 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. The formula applies most straightforwardly to asexual reproduction at a rate of one offspring per time period.
Assume that the green crud population grows at this rate and has a time period of 5 days. Hence, if a green crud population starts out as 10 pounds of crud, then in 5 days there is still 10 pounds of curd; in 10 days there is 20 pounds of crud, in 15 days 30 pounds in 20 days 50 pounds, and so forth. Write a program that takes both the initial size of a green crud population (in pounds) and a number of days as input, and that outputs the number of pounds of green crud after that many days. Assume that the population size is the same for four days and then increases every fifth day. Your program should allow the user to repeat this calculation as often as desired.
Here's what I have so far:
CODE
#include <iostream>
using namespace std;
double population(int pop, int time);
int main()
{
int final, pop, time;
cout<<"Plese enter in the initial size of the green crud."<<endl;
cin>>pop;
cout<<"Please enter in the time in days."<<endl;
cin>>time;
final = population(int pop, time)
cout<<"The number of crud is "<<final<<endl;
return 0;
}
double population(int pop, int time)
{
if(time%5==0)
{
pop = time + pop;
if(time<=5)
pop = 5;
}
else(pop = pop);
return pop;
}
And I got the following errors:
1>c:\users\owner\documents\visual studio 2008\projects\homework5-1\homework5-1\question1.cpp(11) : error C2144: syntax error : 'int' should be preceded by ')'
1>c:\users\owner\documents\visual studio 2008\projects\homework5-1\homework5-1\question1.cpp(11) : error C2660: 'population' : function does not take 0 arguments
1>c:\users\owner\documents\visual studio 2008\projects\homework5-1\homework5-1\question1.cpp(11) : error C2059: syntax error : ')'
Thanks in advance for your help.