The program below is the answer to Deitel’s Java How to Program (9th Edition) Chapter 5 Exercise 5.32.

Question: According to CNNMoney.com, Facebook hit 500 million users in July of 2010 and its user base has been growing at a rate of 5% per month. Using the compound-growth technique you learned in Fig. 5.6 and assuming this growth rate continues, how many months will it take for Facebook to grow its user base to one billion users? How many months will it take for Facebook to grow its user base to two billion users (which, at the time of this writing, was the total number of people on the Internet)?

Solution: Using the technique (compound interest formula),
                                                a = p + (1 + r)n

where a = amount
           p = principal
           r = rate
           n = time (in years)

We are looking for how long the user base will grow to a certain number (time) so we make “n” the subject of the formula and convert “n” to months by multiplying by 12.
                                                n = Math.log(amount/principal) / Math.log(1.0 + rate)

Facebook User Base Growth Calculator in Java
Program Output

Click here to see other answers to Java How to Program.

Write A Comment