Help! I'm not sure how to start or how calculate. This is the project. Using For Next Loops.
- When $1000 is deposited at 5 percent simple interest, the amount grows by $50 each year. When money is invented at 5 percent compound interest, then the amount at the end of each year is 1.05 times the amount at the beginning of that year. Write a program to display the amounts for 10 years for a $1000 deposit at 5 percent simple and compound interest. The first few lines displayed in the list box should appear as in Figure 6.8
--------------------------------------
Amount Amount
Simple Compound
Year Interest Interest
1 $1,050.00 $1,050.00
2 $1,100.00 $1,102.50
3 $1,150.00 $1,157.63
Figure 6.8 Growth of $1000 at simple and compound interest.
---------------------------------------
6 answers
They should be initialized to 1000 as a start.
Write a for-loop that goes over 10 times (years) and accumulate $50 each year for the simple interest case. For the compound interest, multiply the previous amount by 1.05, or AmountCompound=AmountCompound*1.05
Output (inside the loop) the values of AmountSimple and AmountCompound, taking care to limit the number of digits after the decimal point to 2, with rounding.
Create and run your program. Post the code if you have difficulties.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
Dim AmountCompound As Integer = 1000
For AmountSimple As Integer = 1 To 10
AmountSimple = 1000
AmountSimple += 50
If AmountCompound = 1000 Then
AmountCompound = AmountCompound * 1.05
End If
lstOutput.Items.Add(AmountSimple & " Amount Simple Interest" & " ")
lstOutput.Items.Add(AmountCompound & " Amount Compound Interestt" & " ")
Next
End Sub
End Class
0. As suggested, you will need to define AmountSimple and AmountCompound as Decimal. As it is (Integer), you will be able to display to the dollar, no cents.
1. The For variable should not be AmountSimple. Call it Year and declare it before the for statement.
You'll need it for output.
2. "If AmountCompound = 1000 Then... "
The if condition is not needed, it should be multiplied in all 10 cases.
3. The output with a lot of text is hard to read. For 10 years, it is better to make it in table form.
To make the table correctly, you will need some form of format control to display 2 digits after the decimal point. Otherwise it will look like this:
Year Simple Compound
1 1050 1050
2 1100 1102.5
3 1150 1157.625
4 1200 1215.50625
...
Keep up the good work.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim num As Double = 1
Dim Init_Inv As Integer = 1000
Do Until num = 10
Init_Inv = Init_Inv * 1.05
Compound.Items.Add("Year " & num & " | " & FormatCurrency(Init_Inv))
Simple.Items.Add("Year " & num & " | " & FormatCurrency((num * 50) + 1000))
num += 1
Loop
End Sub
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
Dim Compound As Double = 5000
Dim Simple As Double = 5000
Dim i As Integer = 400
lstOutput.Items.Add(vbTab & "Amount" & vbTab & vbTab & "Amount")
lstOutput.Items.Add("Year" & vbTab & "Simple Interest" & vbTab & "Compound Interest")
lstOutput.Items.Add(1 & vbTab & Simple + i & vbTab & vbTab & Compound + (Compound * 0.08))
lstOutput.Items.Add(2 & vbTab & Simple + (i * 2) & vbTab & vbTab & Compound + (Compound * 0.08) * 2)
lstOutput.Items.Add(3 & vbTab & Simple + (i * 3) & vbTab & vbTab & (Compound) + (Compound * 0.08) * 3)
lstOutput.Items.Add(4 & vbTab & Simple + (i * 4) & vbTab & vbTab & Compound + (Compound * 0.08) * 4)
lstOutput.Items.Add(5 & vbTab & Simple + (i * 5) & vbTab & vbTab & Compound + (Compound * 0.08) * 5)
lstOutput.Items.Add(6 & vbTab & Simple + (i * 6) & vbTab & vbTab & Compound + (Compound * 0.08) * 6)
lstOutput.Items.Add(7 & vbTab & Simple + (i * 7) & vbTab & vbTab & Compound + (Compound * 0.08) * 7)
lstOutput.Items.Add(8 & vbTab & Simple + (i * 8) & vbTab & vbTab & (Compound) + (Compound * 0.08) * 8)
lstOutput.Items.Add(9 & vbTab & Simple + (i * 9) & vbTab & vbTab & Compound + (Compound * 0.08) * 9)
lstOutput.Items.Add(10 & vbTab & Simple + (i * 10) & vbTab & vbTab & Compound + (Compound * 0.08) * 10)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Close()
End Sub
End Class