//Cecilia Rangel CSC5 Chapter 6, P.373, #15
//
/**************************************************************
*
* CALCULATE POPULATION SIZE
* ____________________________________________________________
* This program will ask for the user to input a positive
* number, and the program determines if the number is a prime
* number
*
*_____________________________________________________________
* INPUT
* population : size of population
* years : Number of years to display.
* Birth : Annual birth rate.
* Death : Annual death rate.
* OUTPUT
* new : New population size.
*
*
**************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
int calculatePopulation(int popSize, int birthRate, int deathRate);
int main() {
int popSize;
int birthRate;
int deathRate;
int years;
int newPop;
cout << "What is the starting size of a population? ";
cin >> popSize;
if (popSize < 2) {
cout << "Please choose a bigger number for the starting size.";
}
cout << "What is the annual birth rate? ";
cin >> birthRate;
if (birthRate < 0) {
cout << "Please do not choose negative integers.";
}
cout << "What is the annual death rate? ";
cin >> deathRate;
if (deathRate < 0) {
cout << "Please do not choose negative integers.";
}
cout << "What year is it? ";
cin >> years;
if (years < 1) {
cout << "Please do not go lower than 1.";
}
newPop = calculatePopulation(popSize, birthRate, deathRate);
cout << "This is the new population size " << newPop << " new humans in this world in the year " << years;
return 0;
}
//Calculating the new world population with taking the inputs from main
int calculatePopulation(int popSize, int birthRate, int deathRate) {
return (popSize + (birthRate * popSize) - (deathRate * popSize));
}