Menu
CoddyTech

Recap - Price Tag

Part of the PowerShell Basics section of Coddy's PowerShell journey. Lesson 10 of 28.

challenge icon

Challenge

Easy

Print a price tag with a discount.

  1. Create $product with Headphones, $price with 89.99 and $discount with 15 (percent).
  2. Compute the amount saved ($price times $discount, divided by 100) and the price to pay.
  3. Print the five lines below. Prices have a dollar sign and 2 decimals; the discount has a percent sign.

A dollar sign inside double quotes starts a variable name: "$89" is read as a variable named 89. Write it as `$, or use single quotes.

Your script prints:

Product: Headphones
Price: $89.99
Discount: 15%
You save: $13.50
You pay: $76.49

Try it yourself

$product = "Headphones"
$price = 89.99
$discount = 15
# Compute the savings and the price to pay, then print the tag

All lessons in PowerShell Basics