2013-01-23, 09:28 PM
NOTE: I'm a bit of a newbie, but I think I can help.
First of, the pineapple is up with your for loop? Wouldn't that reset the year (popCounter) back to 1980 each time it loops?
As for your real question, you have to multiply the amount the population increases by 1.103 each time it loops, assuming I'm understanding the problem right.
double pop = 231;
int popCounter = 1980;
double percentIncrease = 1.103;
for (popCounter = 1980; popCounter <= 2013; ++popCounter)
{
percentIncrease = percentIncrease * percentIncrease;
}
pop = pop * percentIncrease;
System.out.printf("The population in 2013 is approximately: %f million.", pop);
First of, the pineapple is up with your for loop? Wouldn't that reset the year (popCounter) back to 1980 each time it loops?
As for your real question, you have to multiply the amount the population increases by 1.103 each time it loops, assuming I'm understanding the problem right.
double pop = 231;
int popCounter = 1980;
double percentIncrease = 1.103;
for (popCounter = 1980; popCounter <= 2013; ++popCounter)
{
percentIncrease = percentIncrease * percentIncrease;
}
pop = pop * percentIncrease;
System.out.printf("The population in 2013 is approximately: %f million.", pop);

