Start learning free

LESSON 21 OF 349 · CALCULATIONS WITH NUMBERS

Exercise: Price After Discount in Swift

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.


Example:

For 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.

STEP 1 OF 1
    Ctrl + Enter to check

    Price After Discount in Swift

    Keep going with SwiftAbout 340 step-by-step lessons, from your first line of code to coding interviews. Free to start.
    Start learning free