The program itself is simple enough. However, I'm clueless as to how I should implement this math problem in this for loop... I do have the program itself done, of course.
Code:
public class PopulationGrowth
{
public static void main(String[] args)
{
double pop = 231;
int popCounter = 1980;
for (popCounter = 1980; popCounter <= 2013; ++popCounter)
{
pop = pop * ???????;
}
System.out.printf("The population in 2013 is approximately: %f million.", pop);
}
}
Question marks should be obvious.
Basically, I'm supposed to predict the population growth from 1980 to 2013, with a 1.03% increase from a 231 million population.
I know it's 231 * (1.103)33. My question is... how do I write that in code? Since it's a for loop, the exponential value would be the counter, but that's all I got.
In case you're wondering, this assignment is to practice the use of for loops, so doing it like this is pretty much the entire point of the assignment.
EDIT: IT'S 1.0103 AND SHOULD NOT BE INCLUDING 2013. Okay oops.
Bookmarks