Posted by Lee on Tuesday, November 16, 2010 at 10:57pm.
You will need to declare two decimal variables, AmountSimple, and AmountCompound.
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.
Okay this is my Code: My coding is quite a bit off. Help me please. Thanks.
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
The program almost works! Just missing a few little details.
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.
Thank you MathMate. You were a great help. I was able to finish creating the program and it works correctly..
Related Questions
computers - an introduction to programming and visual basic 2008 page 39 ...
vb programing - I need help to create a project for vb auto center from ...
Computer Programming - Project: I need help getting start on this project. What ...
Computer programming - Sorting is a common operation used in programming. ...
programming and visual basic - These are two different types of questions, these...
Computer - Write the program that will calculate and display the career ...
Programming (Visual Basic) - Im seem to be having trouble with this Exercise. ...
VB - Programming in Visual basic 2008 exercise 11.5 Create a project that store ...
Visual Basic (Computer) - What is programming language syntax? Why is it ...
C++ Programming - Where would I find a great video resource for learning Visual ...
For Further Reading