*LR_DOCTORPINKZ_LR (01)
Member
'Declare the constants and variables.
Const EXEMPTION = 1623.3
Const ONTARIO_TAX_PERCENT = 0.42
Dim Income As Double
Dim FederalTaxes As Double
Dim OntarioTaxes As Double
Dim TotalTaxes As Double
'Prompt the user for the income.
Income = Val(txtIncome.Text)
'Calculate the taxes.
If Income <= 42707 Then
FederalTaxes = Income * 0.15
ElseIf Income <= 85414 Then
FederalTaxes = 6406 + ((Income - 42707) * 0.22)
ElseIf Income <= 132406 Then
FederalTaxes = 15802 + ((Income - 85414) * 0.26)
Else
FederalTaxes = 28020 + ((Income - 132406) * 0.29)
End If
If FederalTaxes < EXEMPTION Then
FederalTaxes = 0
Else
FederalTaxes = FederalTaxes - EXEMPTION
End If
OntarioTaxes = FederalTaxes * ONTARIO_TAX_PERCENT
TotalTaxes = FederalTaxes + OntarioTaxes
'Determine if the results are legal and display the results
If Income < 0 Then
lblFederalTax.Caption = "Invalid Input!"
lblOntarioTax.Caption = "Invalid Input!"
lblTotalTax.Caption = "Invalid Input!"
txtIncome.Text = "Invalid Input!"
Else
lblFederalTax.Caption = Format$(FederalTaxes, "Currency")
lblOntarioTax.Caption = Format$(OntarioTaxes, "currency")
lblTotalTax.Caption = Format$(TotalTaxes, "currency")
txtIncome.Text = Format$(Income, "currency")
End If
Const EXEMPTION = 1623.3
Const ONTARIO_TAX_PERCENT = 0.42
Dim Income As Double
Dim FederalTaxes As Double
Dim OntarioTaxes As Double
Dim TotalTaxes As Double
'Prompt the user for the income.
Income = Val(txtIncome.Text)
'Calculate the taxes.
If Income <= 42707 Then
FederalTaxes = Income * 0.15
ElseIf Income <= 85414 Then
FederalTaxes = 6406 + ((Income - 42707) * 0.22)
ElseIf Income <= 132406 Then
FederalTaxes = 15802 + ((Income - 85414) * 0.26)
Else
FederalTaxes = 28020 + ((Income - 132406) * 0.29)
End If
If FederalTaxes < EXEMPTION Then
FederalTaxes = 0
Else
FederalTaxes = FederalTaxes - EXEMPTION
End If
OntarioTaxes = FederalTaxes * ONTARIO_TAX_PERCENT
TotalTaxes = FederalTaxes + OntarioTaxes
'Determine if the results are legal and display the results
If Income < 0 Then
lblFederalTax.Caption = "Invalid Input!"
lblOntarioTax.Caption = "Invalid Input!"
lblTotalTax.Caption = "Invalid Input!"
txtIncome.Text = "Invalid Input!"
Else
lblFederalTax.Caption = Format$(FederalTaxes, "Currency")
lblOntarioTax.Caption = Format$(OntarioTaxes, "currency")
lblTotalTax.Caption = Format$(TotalTaxes, "currency")
txtIncome.Text = Format$(Income, "currency")
End If