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

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)[SUP]33[/SUP]. 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.
Reply


Messages In This Thread
Using exponential functions in Java. - by MariettaRC - 2013-01-23, 09:04 PM
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)