Write a function subroutine called tax that takes a single argument grossIncome
ID: 3673860 • Letter: W
Question
Write a function subroutine called tax that takes a single argument grossIncome of type Currency. It should calculate the tax on any income using the following tax schedule: (1) if income is less than or equal to $15,000, there is no tax; (2) if income is greater than $15,000 and less than or equal to $75,000, the tax is 15% of all income greater than $15,000; and (3) if income is greater than $75,000, the tax is 15% of all income between $15,000 and $75,000 plus 20% of all income greater than $75,000. Then write a CalcTax sub that asks a user for his income, gets the function subroutine to calculate the tax on this income, and reports the tax in a message box.
Explanation / Answer
Option Explicit
Sub In_Msg()
Dim MyINCOME As Double, MyTAX As Double
On Error GoTo ENDFLAG
MyINCOME = Application.InputBox("Enter your INCOME")
If (MyINCOME > 75000) Then MyTAX = (MyINCOME - 75000) * 0.2 + (75000 - 15000) * 0.15
If (MyINCOME <= 75000) Then MyTAX = (MyINCOME - 15000) * 0.15
If (MyINCOME <= 15000) Then MyTAX = 0
MsgBox MyTAX, vbInformation, "Your TAX is"
ENDFLAG:
End Sub
Function TAX_UDF(MyINCOME As Double) As Variant
TAX_UDF = "Not Possible"
On Error GoTo ENDFLAG
If (MyINCOME > 75000) Then TAX_UDF = (MyINCOME - 75000) * 0.2 + (75000 - 15000) * 0.15
If (MyINCOME <= 75000) Then TAX_UDF = (MyINCOME - 15000) * 0.15
If (MyINCOME <= 15000) Then TAX_UDF = 0
ENDFLAG:
End Function
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.