JRabbit2307 0 Light Poster

Am I on the right track?

Problem: Compute the income tax due on a taxable income entered by the user, given the data as shown on the following table:

Taxable Income Tax Due
From To
$0 $50,000 $0 + 5% of amount over $0
$50,000 $100,000 $2,500 + 7% of amount over $50,000
$100,000 ... $6,000 + 9% of amount over $100,000

Public Class TaxableIncome1

    Private Sub btnCalculateIncomeTax_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculateIncomeTax.Click
        Dim TaxableIncome As Decimal
        Dim TaxDue As Decimal
        TaxableIncome = Convert.ToDecimal(txtTaxableIncome.Text)
        If (TaxableIncome < 0) Then
            MsgBox("Taxable income must be a positive number")
            txtTaxableIncome.Text = ""
        ElseIf TaxableIncome < 50000 Then
            TaxDue = TaxableIncome * 0.05
        ElseIf TaxableIncome < 100000 Then
            TaxDue = (TaxableIncome - 50000) * 0.07 + 2500
        ElseIf TaxableIncome > 100000 Then
            TaxDue = (TaxableIncome - 100000) * 0.09 + 6000
        End If

        lblTaxDue.Text = "Income Tax Due: " & FormatCurrency(TaxDue.ToString())


    End Sub
End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.