Start learning free

LESSON 21 OF 285 · CALCULATIONS WITH NUMBERS

Exercise: Price After Discount

Lesson

We created two variables to store the original price of a product in dollars and the discount percentage applied to that price.

Use these two variables and arithmetic operations to compute and print the price after the discount: what you pay, not the discount itself.


Example:

If price was 150 and discount was 10, the answer would be 135.

Why? Because the discount is 10%. 10% of 150 dollars is 15 dollars. And 150 - 15 dollars is 135 dollars.

Another way: you still pay 100 - 10 = 90% of the price. 90% of 150 dollars is 150 * 90 / 100 = 135 dollars.

STEP 1 OF 1
    Ctrl + Enter to check