Guest User

Untitled

a guest
Jan 18th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. Public Class DisplayListBox
  2.  
  3. Private Sub CalculateButton_Click(sender As System.Object, e As System.EventArgs) Handles CalculateButton.Click
  4. Dim TextBoxPrincipalDouble As Double
  5. Dim TextBoxInterestDouble As Double
  6. Dim TextBoxInt As Integer
  7. Try
  8. TextBoxPrincipalDouble = CDbl(PrincipalTextBox.Text)
  9. TextBoxInterestDouble = CDbl(InterestTextBox.Text)
  10. TextBoxInt = CInt(YearTextBox.Text)
  11. Catch
  12. MessageBox.Show("Please enter valid numbers.", "Entry Error")
  13. End Try
  14. If (TextBoxInterestDouble >= 0 And TextBoxInterestDouble < 1) Then
  15. Dim DepositClass As Deposit = New Deposit(TextBoxPrincipalDouble, TextBoxInterestDouble)
  16. If AccountTypeCheckBox.Checked = True Then
  17. Dim val As CompoundInterestDeposit = New CompoundInterestDeposit(TextBoxPrincipalDouble, TextBoxInterestDouble)
  18. val.CompoundBalance(Year)
  19. Else
  20. Dim val As Deposit = New Deposit(TextBoxPrincipalDouble, TextBoxInterestDouble)
  21. val.TotalBalance(Year)
  22. End If
  23. End If
  24. End Sub
  25. End Class
  26.  
  27.  
  28. Public Class Deposit
  29. Public Interest As Double
  30. Public Deposit As Double
  31. Public Balance As Double
  32.  
  33. Public Sub New()
  34. Interest = 0
  35. Deposit = 0
  36. End Sub
  37. Public Sub New(ByVal Int As Integer, ByVal Dep As Integer)
  38. Interest = Int
  39. Deposit = Dep
  40. End Sub
  41.  
  42. Function TotalBalance(ByVal Year As Integer) As Integer
  43. Balance = Deposit * (1 + (Year * Interest))
  44. Return Balance
  45. End Function
  46. End Class
  47.  
  48. Public Class CompoundInterestDeposit
  49. Inherits Deposit
  50. Public Sub New(ByVal Interest As Integer, ByVal Deposit As Integer)
  51. Interest = 0
  52. Deposit = 0
  53. End Sub
  54. Function CompoundBalance(ByVal Year As Integer) As Integer
  55. Balance = Deposit * (1 + Interest) ^ Year
  56. Return Balance
  57. End Function
  58.  
  59. End Class
Add Comment
Please, Sign In to add comment