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

a = p + (1 + r)

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

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

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)

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

Program Output |

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

## 0 comments:

## Post a Comment

DISCLAIMER: Opinions expressed in comments are those of the comment writers alone and does not reflect or represent the views of the post author. We reserve the right to delete any post deemed inappropriate or offensive and/or spammy.Please do not use abusive words/hate speech.I Appreciate your valuable Feedback. So, Please

DO NOT SPAM- Spam comments will be deleted immediately.Don't use brand name in name field and you're not allowed to use links in comments unless it's necessary. Such comments will be removed immediately. To get notified of replies or follow-up comments, click the box next to notify me.

Thanks.