# Wolfram Language™

## Create a Web Form to Compute the Marginal Tax Rate

In many cases, the computations related to taxes are too complex to be effectively embedded in a single web form. AskFunction allows you to express the computation in a simple and intuitive way.

In:= ```CloudDeploy[AskFunction[Module[{bracket, tax, income}, bracket = Ask[{"brackets", "What is your marital status?"} -> {"Married filing jointly" \ -> {18550, 75300, 151900, 231450, 413350, 466950}, "Single" -> {9275, 37650, 91150, 190150, 413350, 415050}, "Head of household" -> {13250, 50400, 130150, 210800, 413350, 441000}, "Married filing separately" -> {9275, 37650, 75950, 115725, 206675, 233475}}]; income = Ask[{"income", "What was your income in 2015"} -> Restricted["Number", {0, Infinity}]]; tax = Integrate[ Piecewise[{{.10 , 0 <= x <= bracket[]}, {.15, bracket[] < x <= bracket[]}, {.25, bracket[] < x <= bracket[]}, {.28, bracket[] < x <= bracket[]}, {.33, bracket[] < x <= bracket[]}, {.35, bracket[] < x <= bracket[]}, {.396, True}}], {x, 0, income - If[Ask[{"deps", "Do you have any dependents?"} -> {"Yes" -> True, "No" -> False}], Ask[{"nodeps", "How many?"} -> Restricted["Integer", {0, Infinity}]]* 4050, 0]}]; AskTemplateDisplay[ Column[{"You owe \$" <> ToString[tax] <> " in taxes.", "Your marginal tax rate is " <> ToString[Round[100.*tax/#income, 0.1]] <> "%", PieChart[{tax, income}]}] &] ]]]```

As you can see in this example, you can use the programming style you prefer, using Module and storing the state of your computation. AskFunction will also skip questions that are not needed. Try it for yourself.    