Group Abstract Group Abstract

Message Boards Message Boards

0
|
36 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

Calculating reverse sales tax

Posted 18 hours ago

I was exploring a simple reverse sales-tax calculation in Wolfram Language while working on a small calculator project.

For a final price of $108 with an 8% sales tax:

108/(1 + 8/100)

gives:

100

So the pre-tax price is $100.

I then generalized the calculation as:

reverseTax[price_, rate_] := price/(1 + rate/100)

I'm curious how other Wolfram Language users would approach this. Would you use Manipulate to turn it into a small interactive calculator, or is there a more idiomatic way to structure this?

I'm also wondering how you would handle things like rounding the result to two decimal places and preventing invalid inputs, such as a negative tax rate. Would you handle that validation inside DynamicModule/Manipulate, or separately?

For anyone interested in the practical application, I also put together a simple online version of the reverse-tax calculation at https://calculatereversetax.com.

POSTED BY: Alex Calculates

Here is a little attempt using InpurField:

DynamicModule[{price = 108, rate = 8},
 Column[{
   Row[{"price = ",
     InputField[Dynamic[price]]}],
   Row[{"rate = ",
     InputField[Dynamic[rate]]}],
   Row[{"reverse = ",
     Dynamic[price/(1 + rate/100) // N]}]}]]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard