I'm not entirely sure what you're supposed to be doing there (it took me a while to realize that you weren't talking about music on discs, but that really doesn't matter). However it sounds to me like you're supposed to be adding something to the CD value each time through the loop. Am I right? I don't see any code which does that.
I think its more of a finance issue than a programming one. A CD (certificate of deposit) with an APY and a maturity period means you're just putting X dollars in and getting X+(percent of X) back after that period is finished. So the value of that investment doesn't change from month to month. Maybe the bank pays out that extra value in monthly installments, but it should always be a fixed amount. So ft that's the case, its best to calculate it before your loop. Then all the loop will do is add that value to your initial deposit after each month.
That's just my non-professional understanding of CD's (I have had them before though). Maybe some clarification of the assignment will help.
I tried a different approach this afternoon, but the math is still incorrect.
The assignment is:
(Financial application: compute CD value) Suppose you put $10,000 into a CD
with an annual percentage yield of 5.75%. After one month, the CD is worth
10000 + 10000 * 5.75 / 1200 = 10047.91
After two months, the CD is worth
10047.91 + 10047.91 * 5.75 / 1200 = 10096.06
After three months, the CD is worth
10096.06 + 10096.06 * 5.75 / 1200 = 10144.43
and so on.
Liang, Y. Daniel (2012-04-26). Introduction to Java Programming, Comprehensive Version (2-download) (9th Edition) (Page 172). Prentice Hall. Kindle Edition.
Yeah that's not how APY works. APY is already supposed to already take the compounding of the interest into account.
But yeah if you ignore that for now and just deal with a monthly interest rate then you should just use what was given as your example as what goes in your loop.
"After two months, the CD is worth
10047.91 + 10047.91 * 5.75 / 1200 = 10096.06 "
Remember in java "=" doesn't mean "equivalent to" like in mathematics, its more like "set to". For example you can update the value of x with x = x + 1;
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop