Instructions
Calculate the discount based on the following rules:
- If the purchase amount is greater than or equal to 1000, apply a discount of 20%.
- If the purchase amount is between 500 and 999 (inclusive), apply a discount of 10%.
- If the purchase amount is less than 500, apply no discount.
Solution
Decimal discount = (purchaseAmount >= 1000) ? purchaseAmount * 0.20 :
(purchaseAmount >= 500) ? purchaseAmount * 0.10 :0;