Ok, the program I am supposed to code is using Fibonacci's numbers.(Yes, this is an assignment) I thought I had the answer, so I got to coded. But my program keeps yielding a ridiculous random number.
The assignment is
" Assume that green crud grows at the rate of Fibonnaci's numbers and has a 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; 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 the crud 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."
Here is my source code:
#include<iostream>using namespace std;int greencrud(int numberof_crud, int crud_days, int amount_crud);int greencrud(int numberof_crud, int crud_days, int amount_crud){ for(int i = 1; i <= crud_days; i++) { do{ amount_crud = amount_crud + amount_crud; numberof_crud = amount_crud; } while(crud_days % 5 == 0); }return numberof_crud;}int main() { cout << "Welcome to Crud Estimator\n"; cout << "Please enter the number of days the crud has been grown \n"; int crud_days = 0; cin >> crud_days; cout << "Please enter the original amount of crud "; int amount_crud; cin >> amount_crud; cout << "\nThe number of crud you have in your household is " << greencrud(numberof_crud); return 0;}
[Edited by - Blckknight118 on October 18, 2010 6:20:40 PM]