HELP with computations

kidrobot

Registered User.
Local time
Today, 06:33
Joined
Apr 16, 2007
Messages
409
Code:
for (i=1; i<=36; i++) 
{ 
      interest = deposit * .03; 
      balance = deposit * 1.03;
      TotalInterest = balance - deposit; 
      deposit = balance; 
     
}

I'm trying to make an interest calculator. I'm trying to get the balance,interest, and total interest for 3 years(my equations are above). the user will input the deposit amount, so if the user enters "100" the following would be outputted.

Month Balance Interest Total Interest
1 ----103------ 3.00---- 3.00----
2 ----106.09---- 3.09---- 6.09----
3 ----109.27 ----3.18---- 9.27----

currently i'm getting...
Month Balance Interest Total Interest
1 ----103 ------3.00 ----3.00----
2 ----106.09 ----3.09 ----3.09----
3 ----109.27 ----3.18 ----9.27----
(my interest and total interest are the same for some weird reason!) Please help me I've never been great with equations!!!!

Thanks
 
Hi Kid,

Where are you getting 3% a month ... I want a piece of that.

That's "C" code too.

Anyway, not mathematically 100% accurate, but should give you an idea.

Code:
Dim i As Integer
Dim Interest As Single
Dim CurrentTotal As Single
Dim TotalInterest As Single
Dim InitialDeposit As Single

InitialDeposit = 100#
CurrentTotal = InitialDeposit

For i = 1 To 36
   Interest = Round(CurrentTotal * 0.03, 2)
   CurrentTotal = Round(CurrentTotal * 1.03, 2)
   TotalInterest = Round(CurrentTotal - InitialDeposit, 2)
   Debug.Print CurrentTotal, TotalInterest
   Next i

Wayne
 
Wayne, I'm sorry I wasn't 100% clear but this is for JAVA. I was thinking that it would be the same concept as VB, but do you know how to do "Next i" in JAVA by any chance? sorry to be a little deceiving but this is the only programming forum I am apart of!
 

Users who are viewing this thread

Back
Top Bottom