-2
절차 및 기능을 사용하여 소득세 계산기를 만들려고합니다. 코드는 설명이 있어야합니다. 모든 것이 0의 값을 반환합니다. 누군가 내가 잘못 가고있는 부분에 대해 약간의 통찰력을 줄 수 있습니까?Visual Basic 절차 및 절차
Partial Class TaxCalcualtor
Inherits System.Web.UI.Page
Private totalWages As Decimal
Private taxesWithheld As Decimal
Private deductions As Integer
Private married As Boolean
Private taxLiability As Decimal
Private federalTaxes As Decimal
Private stateTaxes As Decimal
Private localTaxes As Decimal
Function SingleFunction(ByVal totalWages As Decimal, ByVal married As Boolean, ByVal taxLiability As Decimal) As Decimal
Dim taxRate As Decimal
totalWages = CDec(TextBoxWages.Text)
If married = False And totalWages < 25000.0 Then
taxRate = 0.15
ElseIf married = False And totalWages >= 25000.0 And totalWages < 45000.0 Then
taxRate = 0.18
ElseIf married = False And totalWages >= 45000.0 And totalWages < 65000.0 Then
taxRate = 0.22
ElseIf married = False And totalWages >= 65000.0 And totalWages < 85000.0 Then
taxRate = 0.28
ElseIf married = False And totalWages >= 85000.0 And totalWages < 100000.0 Then
taxRate = 0.32
ElseIf married = False And totalWages >= 100000.0 Then
taxRate = 0.35
End If
taxLiability = taxRate * totalWages
Return taxLiability
End Function
Function SingleMarriedFunction(ByVal totalWages As Decimal, ByVal married As Boolean, ByVal taxLiability As Decimal) As Decimal
Dim taxRate As Decimal
totalWages = CDec(TextBoxWages.Text)
If married = True And totalWages < 25000.0 Then
taxRate = 0.13
ElseIf married = True And totalWages >= 25000.0 And totalWages < 45000.0 Then
taxRate = 0.16
ElseIf married = True And totalWages >= 45000.0 And totalWages < 65000.0 Then
taxRate = 0.18
ElseIf married = True And totalWages >= 65000.0 And totalWages < 85000.0 Then
taxRate = 0.2
ElseIf married = True And totalWages >= 85000.0 And totalWages < 100000.0 Then
taxRate = 0.22
ElseIf married = True And totalWages >= 100000.0 Then
taxRate = 0.24
End If
taxLiability = taxRate * totalWages
Return taxLiability
End Function
Function FederalTax(ByVal taxWithheld As Decimal, ByVal taxLiability As Decimal, ByVal deductions As Integer) As Decimal
Dim federalTaxes As Decimal
taxesWithheld = CDec(TextBoxTaxesWithheld.Text)
federalTaxes = taxWithheld - taxLiability - (deductions * 750)
Return federalTaxes
End Function
Function StateTax(ByVal totalWages As Decimal) As Decimal
Dim stateTaxes As Decimal
totalWages = CDec(TextBoxWages.Text)
stateTaxes = totalWages * 0.06
Return stateTaxes
End Function
Function LocalTax(ByVal totalWages As Decimal) As Decimal
Dim localTaxes As Decimal
totalWages = CDec(TextBoxWages.Text)
localTaxes = totalWages * 0.01
Return localTaxes
End Function
Sub DisplayData()
Label7.Text += "Tax Liability: " + CStr(taxLiability)
Label7.Text += "Federal Taxes: " + CStr(federalTaxes)
Label7.Text += "State Taxes: " + CStr(stateTaxes)
Label7.Text += "Local Taxes: " + CStr(localTaxes)
End Sub
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
DisplayData()
End Sub
End Class
원하는 동작 : 계산 세금 책임, 연방, 주 및 지방 세금 문제 : 모든 값은 당신이 초기화 된 적이없는 값을 표시하는 0 – Bob
을 반환하는이/수정했습니다. 코드가 더 이상 없으면 * taxLiability *는 절대로 수정되지 않습니다. 계산 함수는 절대로 호출되지 않습니다. – Bob
"SingleFunction"및/또는 "SingleMarriedFunction"을 절대 호출하지 않습니다. 또한 아무것도 변경하지 MarriedFunction이라고해서는 안됩니다. 또한 전역 변수는 함수에서 전달하는 것과 동일한 로컬 변수 이름으로 호출하면 안됩니다. 함수의 목적은 전달한 모든 정보에서 값을 반환하는 것입니다. 당신은 여러 곳에서 세금 계산을 변경하고 있지만 그것은 또한 많은 장소에서 선언됩니다. 그 때문에 혼란스러워하고 있습니다. 컴퓨터는 당신이 정말로 원하는 마녀 하나를 알지 못해 당신에게 지역의 것을 돌려줍니다. – Chillzy