Depends on what you want to output.

If you only require the final balance at the end of a number of years, then your 
equation is

  finalBalance = initialBalance * Math.pow (interestRate, numberOfYears);

If you want each year separately, then you simply use a "for" loop to calculate it 
year by year, multiplying the balance for the year by 1 + 4.5% or 1.045.

Note however, that your example numbers do not support this.  The first four years 
should be

$1000.00
$1045.00
$1092.03
$1141.17

not what you've got.  Does this mean that you want to make an extra deposit during 
year 3?

Dave S

  ----- Original Message ----- 
  From: exvisu 
  To: [EMAIL PROTECTED] 
  Sent: Friday, October 29, 2004 1:49 AM
  Subject: [Java] Compound interest, I need help til the Java Code




  I have got an exercise about compound interest.

  Year 1 is 1000 � deposit in the bank. 
  At the end of the year the deposit is increased with an interst of 
  4.5%. 
  Year 2 The balance is now 1045 � + 1000 * 4.5%
  Year 3 2137.07 * 4.5 %
  Year 4 2233.24

  How do I write this i Java

  I hope you can help me


  ---
  Outgoing mail is certified Virus Free.
  Checked by AVG anti-virus system (http://www.grisoft.com).
  Version: 6.0.783 / Virus Database: 529 - Release Date: 26/10/04

[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/5cFolB/TM
--------------------------------------------------------------------~-> 

If you have any comments or questions, submit it on the message board.
NO spam/ads/job posting or you will be BANNED from this group. Exception can be made 
it happen by notify me ahead of time.
all new members' message will be verified by me (spam..) before it get posted. 
Yahoo! Groups Links

<*> To reply to this message, go to:
    http://groups.yahoo.com/group/java_official/post?act=reply&messageNum=17290
    Please do not reply to this message via email. More information here:
    http://help.yahoo.com/help/us/groups/messages/messages-23.html

<*> To visit your group on the web, go to:  
    http://groups.yahoo.com/group/java_official/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to