Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles performCalc.Click
'Specify constant values
Const INTEREST_CALCS_PER_YEAR As Integer = 12
Const PAYMENTS_PER_YEAR As Integer = 12
'Create variables to hold the values entered by the user
Dim P As Double = loan.Text
Dim r As Double = rate.Text / 100
Dim T As Double = mortgageLenght.Text
Dim ratePerPeriod As Double
ratePerPeriod = r / INTEREST_CALCS_PER_YEAR
Dim payPeriods As Integer
payPeriods = T * PAYMENTS_PER_YEAR
Dim annualRate As Double
annualRate = Math.Exp(INTEREST_CALCS_PER_YEAR * Math.Log(1 + ratePerPeriod)) - 1
Dim intPerPayment As Double
intPerPayment = (Math.Exp(Math.Log(annualRate + 1) / payPeriods) - 1) * payPeriods
'Now, compute the total cost of the loan
Dim intPerMonth As Double = intPerPayment / PAYMENTS_PER_YEAR
Dim costPerMONTH As Double
costPerMONTH = P * intPerMonth / (1 - Math.Pow(intPerMonth + 1, -payPeriods))
'Now, display the results in the results Label Web control
results.Text = "Your mortgage payment per month is Php" & costPerMONTH
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub performCalc_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles performCalc.Click
End Sub
End Class
No comments:
Post a Comment