Wow... ive been working on this for three hours today. I admit, my math is lacking... but I didn't think it was this bad. Please excuse all my extra variables.
Someone please help me with this... Im pulling my hair out at this point. lol
And i've reviewed the tutorials on fibonacci numbers. I really need to hear the explanation in terms of this question:
"It takes an organism two time periods to mature to reproduction age, and then the organism reproduces once per time period...
Assume that this green crud pile organism grows at this rate. 1 time period = 5 days. Hence, if a green crud population starts out as 10 pounds of crud, then in 5 days there will still be 10 pounds, 10 days: 20 pounds, 15 days: 30 pounds, 20 days: 50 pounds. Write a program that takes both the initial size of the population (in lbs) and the # of days it will mature. Assume that the population size is the same for 4 days, then doubles on the 5th."
Thank you. I look forward to fresh info... Im going to go have a drink. lol
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
//Global constants
//Function Prototypes
//Execution
int main(int argc, char** argv) {
//Variables
float isize, time, growth, growth2, growth3, rate, fib, n;
//Input
cout<<"Input the initial size of green crud in pounds"<<endl;
cin>>isize;
growth=isize;
cout<<"Input how many days you would like to have the population grow"<<endl;
cin>>time;
rate=time/5;
if ((1==rate)||(2==rate)) {
cout<<"Population size is"<<isize<<endl;
}
else {
while (rate>=3) {
growth2=growth++;
growth3=growth2++;
growth=growth2+growth3;
rate--;
}
cout<<"Crud pile is "<<growth<<endl;
}
return 0;
}
|