Start learning free

LESSON 20 OF 348 · CALCULATIONS WITH NUMBERS

Exercise: Find Discount in Rust

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 discount amount in dollars.


Example:

For example, if price was 150 and discount was 10, the answer would be 15.

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

STEP 1 OF 1
    Ctrl + Enter to check

    Find Discount in Rust

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