need a point in the right direction
I'm trying to take the population of a town which increases by 10% each year and determine how long until population = 10,001.
I had it working until I decided to put in the last cout statement that recalls the original input value of the population.
Is there a way to do that?
Thanks
**Please note: I am not asking anyone to do my homework for me, I would just like a point in the right direction. Thanks.
Code:
#include <iostream>
#include <cmath>
using namespace std;
//Functions used ...(function prototypes)
void instructions ();
int calculations ();
int numYears;
int population;
int populationTotal;
float rate;
-----------------------------------------------
int main ()
{
instructions ();
calculations ();
cout << endl;
return 0;
}
-----------------------------------------
void instructions ()
{
cout << "This program determines the number "
<< "of years it will take for a "
<< "town's population"
<< "to reach more than 10,001 at a growth rate "
<< "of 10% per year." << endl << endl;
}
------------------------------
int calculations ()
{
cout << "Please enter the current population: ";
cin >> population;
rate = 1.1;
for (int numYears = 0; populationTotal <= 10001; numYears++)
{
populationTotal = populationTotal * rate;
}
populationTotal = population * 1;
cout << "With an initial population of "
<< population
<< ", it will take "
<< numYears
<< " years" << endl;
cout << "for the population to become "
<< "more than 10,001." << endl << endl;
return 0;
}