Recap - Price Tag
Part of the PowerShell Basics section of Coddy's PowerShell journey. Lesson 10 of 28.
Challenge
EasyPrint a price tag with a discount.
- Create
$productwithHeadphones,$pricewith89.99and$discountwith15(percent). - Compute the amount saved (
$pricetimes$discount, divided by 100) and the price to pay. - 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.49Try 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
5Project: Password Checker
Project OverviewLength Check