i have been interested in the game spore thats coming out soon and, i wanted to make my own text based spore game but i cant get it to count out the population growth per day the logic seems fine to me but the problem might be near the while loop can some show me whats wrong.
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
int pop,days,total;
//float incres;
//user gives the size of the pop
cout<<"please enter the number of population: ";
cin >>pop;
Hi, there are a coupel of things that need fixing, from what I can tell (using # format would make things easier).
First is in your logic for entering the varaibles. You have used return main();. AFAIK this will recursivly call main() (as you are in main()).
A better solution woudl be to have the two data entry parts as simple functions
EG;
1 2 3 4 5 6
int enterPop()
{
cout<<"please enter the number of population: ";
cin >>pop;
return pop;
}
then in main()
1 2 3 4 5 6 7 8
do
{
pop = enterPop();
if (pop<2)
{
cout<<"Error you are doing it wrong, need at least 2 population"<<endl;
}
} while (pop<2);
Secondly the population output loop should be
1 2 3 4 5
for (int currentDay = 1; currentDay <=days; currentDay++)
//Loop from 1 to number of days
{
//Calculations here
}