Method Deck / finance
Discount and markup
Applies a percentage discount or a percentage markup to a price and returns the new price and the dollar change.
Published for review. The Founder is checking every card himself; anything he strikes comes down the same hour.
Try it
Inputs
- price (number, currency units, required) min 0 : Original price
- percent (number, %, required) min 0 : Discount or markup percentage
- mode (string, required) one of: discount, markup : Whether to apply a discount or a markup
Outputs
- new_price (currency units): Price after the discount or markup
- amount_change (currency units): Dollar amount of the discount or markup
Steps
- Convert the percent to a decimal: p = percent / 100.
- amount_change = price * p.
- If mode is discount, new_price = price - amount_change; if mode is markup, new_price = price + amount_change.
- Round new_price and amount_change to 2 decimals (money to cents).
Constants
None.
Sources
Worked example and test vectors
| Name | Inputs | Answer |
| worked example | {"price":80,"percent":25,"mode":"discount"} | $60.00 |
| test vector: markup | {"price":150,"percent":40,"mode":"markup"} | $210.00 |
Published card
- Address:
251a9263a9fb97bca6572c2fedb04f20
- Made at:
2026-09-30T22:39:30.722Z
- Method sha256:
930d26f3c36600e17119d6076c26cf84f7593f695cca543c1ebea9ff1fdeb185