I have 1 line in this code that I can't get to compile. I'm new to C++ and begging for some help...any advise would be appreciated.
#include <iostream>
#include <iomanip>
using namespace std;
double population(double pop, double birthRate, double deathRate);
void printPopulations(
double startPop, double birthRate, double deathRate, int numYears);
double population(double pop, double birthRate, double deathRate)
{
double n = 0;
n = pop + (birthRate*pop) - (deathRate*pop);
return n;
}
void printPopulations(double startPop, double birthRate, double deathRate, int numYears)
{
for ( int i = 0 ; i < numYears ; i++ )
{
startPop = population (double birthRate, double deathRate, numYears, double n);
cout << "For year " << i+1 << " the population is " << startPop << endl ;
}
}
int main()
{
double startPop,
birthRate,
deathRate;
int numYears;
cout << "This program calculates population change.\n";
cout << "Enter the starting population size: ";
cin >> startPop;
while (startPop < 2.0)
{
cout << "Starting population must be 2 or more. Please re-enter: ";
cin >> startPop;
}
cout << "Enter the annual birth rate (as % of current population): ";
cin >> birthRate;
while (birthRate < 0)
{
cout << "Birth rate percent cannot be negative. Please re-enter: ";
cin >> birthRate;
}
birthRate = birthRate / 100;
cout << "Enter the annual death rate (as % of current population): ";
cin >> deathRate;
while (deathRate < 0)
{
cout << "Death rate percent cannot be negative. Please re-enter: ";
cin >> deathRate;
}
deathRate = deathRate / 100;
cout << "For how many years do you wish to view population changes? ";
cin >> numYears;
while (numYears < 1)
{
cout << "Years must be one or more. Please re-enter: ";
cin >> numYears;
}
printPopulations(startPop, birthRate, deathRate, numYears);
system ("pause");
return 0;
}