• Post Reply Bookmark Topic Watch Topic
  • New Topic

loop to work with formula to calcuate new value of a CD  RSS feed

 
Ben Abrams
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Can anyone help me get this to work correctly?

It's suppose to generate a table with the month, and the new amount of the CD. Right now, the program generates a continuous table for months, but it doesn't update the value of the CD.

This is a homework assignment. I don't expect anyone to "hand" me the answer.

Thanks for any assistance.

 
Paul Clapham
Sheriff
Posts: 22829
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Tyson Lindner
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ben Abrams
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Here is my "different attempt":

 
Paul Clapham
Sheriff
Posts: 22829
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:[i]t sounds to me like you're supposed to be adding something to the CD value each time through the loop. I don't see any code which does that.
 
Tyson Lindner
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah that's not how APY works. APY is already supposed to already take the compounding of the interest into account.
explanation

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;
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!