Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class DisplayListBox
- Private Sub CalculateButton_Click(sender As System.Object, e As System.EventArgs) Handles CalculateButton.Click
- Dim TextBoxPrincipalDouble As Double
- Dim TextBoxInterestDouble As Double
- Dim TextBoxInt As Integer
- Try
- TextBoxPrincipalDouble = CDbl(PrincipalTextBox.Text)
- TextBoxInterestDouble = CDbl(InterestTextBox.Text)
- TextBoxInt = CInt(YearTextBox.Text)
- Catch
- MessageBox.Show("Please enter valid numbers.", "Entry Error")
- End Try
- If (TextBoxInterestDouble >= 0 And TextBoxInterestDouble < 1) Then
- Dim DepositClass As Deposit = New Deposit(TextBoxPrincipalDouble, TextBoxInterestDouble)
- If AccountTypeCheckBox.Checked = True Then
- Dim val As CompoundInterestDeposit = New CompoundInterestDeposit(TextBoxPrincipalDouble, TextBoxInterestDouble)
- val.CompoundBalance(Year)
- Else
- Dim val As Deposit = New Deposit(TextBoxPrincipalDouble, TextBoxInterestDouble)
- val.TotalBalance(Year)
- End If
- End If
- End Sub
- End Class
- Public Class Deposit
- Public Interest As Double
- Public Deposit As Double
- Public Balance As Double
- Public Sub New()
- Interest = 0
- Deposit = 0
- End Sub
- Public Sub New(ByVal Int As Integer, ByVal Dep As Integer)
- Interest = Int
- Deposit = Dep
- End Sub
- Function TotalBalance(ByVal Year As Integer) As Integer
- Balance = Deposit * (1 + (Year * Interest))
- Return Balance
- End Function
- End Class
- Public Class CompoundInterestDeposit
- Inherits Deposit
- Public Sub New(ByVal Interest As Integer, ByVal Deposit As Integer)
- Interest = 0
- Deposit = 0
- End Sub
- Function CompoundBalance(ByVal Year As Integer) As Integer
- Balance = Deposit * (1 + Interest) ^ Year
- Return Balance
- End Function
- End Class
Add Comment
Please, Sign In to add comment