Wolfram Language

Interfaces de la nube y web

Cree un formulario web para calcular la tasa impositiva marginal

En algunos casos, los cálculos relacionados con impuestos son muy complejos para ser incrustados efectivamente en un sólo formulario web. AskFunction le permite expresar el cálculo en una forma simple e intuitiva.

In[1]:=
Click for copyable input
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[[1]]}, {.15, bracket[[1]] < x <= bracket[[2]]}, {.25, bracket[[2]] < x <= bracket[[3]]}, {.28, bracket[[3]] < x <= bracket[[4]]}, {.33, bracket[[4]] < x <= bracket[[5]]}, {.35, bracket[[5]] < x <= bracket[[6]]}, {.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}]}] &] ]]]
Out[1]=

Como puede ver en este ejemplo, usted puede utilizar el estilo programático que prefiera, usando Module y almacenando el estado de su cálculo. AskFunction también se saltará las preguntas que no son necesarias. Pruébelo usted mismo.

Ejemplos relacionados

de en fr ja ko pt-br ru zh