Something like this?
Code:
#include <iostream>
#include <cstring>
#include <cmath> //floor()
using namespace std;
const double BOOM_FACTOR = 1.15;
const double BAD_FACTOR = 0.8;
int main()
{
double population = 0;
char userChoice = 'y';
cout << "Enter a starting population size: ";
cin >> population;
double PredictBoomPopulation;
double PredictBadPopulation;
//std::floor: 0.67 humans don't exist.
//Let's add 0.5 because of rounding errors during conversion.
PredictBoomPopulation = floor(population* BOOM_FACTOR);
PredictBadPopulation = floor(population *BAD_FACTOR);
cout << "After a boom year, your population will grow to: "
<< PredictBoomPopulation << endl;
cout << "After a bad year, your population will shrink to: "
<< PredictBadPopulation << endl;
do
{
cout<<endl;
cout << "Was it a boom or BAD year (o/a)? ";
cin >> userChoice;
if (userChoice == 'o')
{
population = floor(PredictBoomPopulation);
}
if (userChoice == 'a')
{
population = floor(PredictBadPopulation);
}
cout<<"Population: "<<population<<endl<<endl;
PredictBoomPopulation = floor(population* BOOM_FACTOR+.5);
PredictBadPopulation = floor(population *BAD_FACTOR+.5);
cout << "After a boom year, your population will grow to: "
<< PredictBoomPopulation << endl;
cout << "After a bad year, your population will shrink to: "
<< PredictBadPopulation << endl;
cout<<"Do you wish to continue program? (yes = y): ";
cin>>userChoice;
} while(userChoice == 'y');
cout<<"Program terminated."<<endl;
return 0;
}