English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Write a C++program that calculates the amount of time necessary to reach a certain financial goal by consistently depositing the same amount of money into an interest bearing account each month. The account is compounded monthly.

2007-02-22 15:28:42 · 3 answers · asked by stokes4show 2 in Computers & Internet Programming & Design

3 answers

You use the formula that Amount To Be Saved = Monthly Principal Amount * Interest * Number of Deposits. You need to know three of those items to calculate the fourth.

The exercise asks you to calculate the number of payments that need to be made. That means you will actually calculate Number of Deposits = Amount To Be Saved / (Monthly Principal Amount * Interest).

So, you ask the user for the amount to be saved, the interest rate to be used and the desired monthly principal amount.

Suppose the person enters $1,000 as the amount to be saved, 5 percent as the interest and $30 as the monthly payment.

In that case, 1000 / (1.05 * 30) = 31.7 ~ 32. It would take 32 months to save $1,000 at a 5 percent interest rate and a monthly deposit of $30. If there was no interest, it would have taken 34 months.

Suppose the person enters $5,000 as the amount to be saved, 10 percent as the interest and $50 as the monthly payment. 5000 / (1.1 *50) = 90.9 ~ 91 months. If there was no interest, it would have taken 100 months.

2007-02-22 16:05:55 · answer #1 · answered by Anonymous · 1 0

If my target is $1000 and the interest is 5% and I invest $30 per month. With compound interest I make the target 20 months!!!!

If you are going to write a program it pays to know what output you should expect. It also helps with testing.

The rest should not be too difficult if you use a while loop with a test to exit when the investment is greater than the target.

2007-02-23 00:35:39 · answer #2 · answered by AnalProgrammer 7 · 0 0

Homework?

What you need to do is figure out how you would calculate it by hand, and then use that as the algorithm for your code.

2007-02-22 15:37:07 · answer #3 · answered by aperson 3 · 0 0

fedest.com, questions and answers