Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using exponential functions in Java.
#6
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);
Reply


Messages In This Thread
Using exponential functions in Java. - by Locked - 2013-01-23, 09:10 PM
Using exponential functions in Java. - by JoeTang - 2013-01-23, 09:23 PM
Using exponential functions in Java. - by Locked - 2013-01-23, 09:27 PM
Using exponential functions in Java. - by Maping - 2013-01-23, 09:28 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)