Computer Science, asked by yatharthsoni610, 1 year ago

write a VB program to calculate and display the compound interest based on the principal amount ,rate of interest and time period that a user enters​

Answers

Answered by abdallahsomaliboy
0

Answer:Private Sub cmdCalculate_Click()

Dim principle As Double

Dim interest_rate As Double

Dim num_years As Integer

Dim i As Integer

Dim current_value As Double

   lstBalances.Clear

   principle = Val(txtPrinciple.Text)

   interest_rate = Val(txtInterestRate.Text)

   num_years = Val(txtYears.Text)

   For i = 1 To num_years

       current_value = principle * (1 + interest_rate) ^ i

       lstBalances.AddItem i & ": " & _

           vbTab & FormatCurrency(current_value)

   Next i

End Sub

Explanation:

The program simply loops through the years, evaluating the compound interest formula:

   balance = principle * Math.Pow(1 + interestRate, i)

Interesting tidbit: To estimate how long it will take to double your money, you can use the "Rule of 72." Divide the interest rate into 72 and the result tells you roughly how many years it will take to double your money. For example, at 7.2% it'll take about 10 years. It's a pretty decent estimate.

Similar questions