Sales tax is a percent layered on top of a subtotal, but the layering rules vary by jurisdiction. Some regions add the tax at the till; some bake it into the shelf price. Some apply different rates to different categories — groceries, prepared food, online subscriptions — and some compound state and local taxes. The math itself is one multiplication and one addition; the complexity sits in the rules around it.
This page focuses on the math. The worked example uses a $145 subtotal at an 8% combined rate, but the same formula handles any rate from 0% to 25% just as cleanly.