Hi, all
I need a "For loop" source code to do like capital and interest calculation.
for example:
I put $100 in a bank, 7% interest rate, for 2 years, compounded annually.
Thank you so much
Printable View
Hi, all
I need a "For loop" source code to do like capital and interest calculation.
for example:
I put $100 in a bank, 7% interest rate, for 2 years, compounded annually.
Thank you so much
Is this homework? Anyway heres a start
VB Code:
Dim Amount As Double = 100 '100$ Dim Interest As Single = 7 '7% Dim Years As Integer = 2 'left in for 2 yrs Dim OnePercent As Double Dim InterestAdded As Double For i As Integer = 1 To Years 'loop through each yr OnePercent = Amount / 100 'divide balance by 100 to give 1% InterestAdded = OnePercent * Interest 'calculate interest earnings Amount += InterestAdded 'add interest to amount Next MessageBox.Show("After " & Years & " years at an interest rate of: " & Interest.ToString & "% your balance would be: " & Amount.ToString("c"))
the182guy, thank you so much
one more question, can I write such thing in vb:
amount = (1 + interest) ^ year
Thank you