**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}

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)

1 2 |
/**<br /> *<br /> * @Author: Aghatise Osazuwa<br /> * Website: www.cscprogrammingtutorials.com<br /> *<br /> * Exercise 5.32 - Facebook User Base Growth<br /> *<br /> */ <br /><br />public class FBUserGrowth {<br /> public static void main (String [] args) {<br /> System.out.println("nnThis Program Calculates How Many Months Facebook Users Will Reach " <br /> + "1,000,000,000 and 2,000,000,000.");<br /><br /> double n; <br /> double principal = 500000000.0; // initial amount before interest<br /> double rate = 0.05;<br /> double amount = 1000000000.0;<br /> n = Math.log(amount/principal)/Math.log(1.0 + rate);<br /> System.out.printf("nUser base will be 1,000,000,000 in %d months.n", Math.round(n*12));<br /> amount = 2000000000.0;<br /> n = Math.log(amount/principal)/Math.log(1.0 + rate);<br /> System.out.printf("nUser base will be 2,000,000,000 in %d months.nn", Math.round(n*12));<br /> }<br />}<br /> |

Program Output |