0
0
PowerShellscripting~15 mins

Arithmetic operators in PowerShell - Mini Project: Build & Apply

Choose your learning style9 modes available
Arithmetic operators
📖 Scenario: You are helping a small shop owner calculate the total cost of items bought by a customer. You will use arithmetic operators in PowerShell to add, subtract, multiply, and divide numbers.
🎯 Goal: Build a simple PowerShell script that uses arithmetic operators to calculate the total price, discount, tax, and final amount to pay.
📋 What You'll Learn
Create variables for item prices and quantities
Create a variable for discount percentage
Calculate total price before discount
Calculate discount amount using multiplication
Calculate price after discount using subtraction
Calculate tax amount using multiplication
Calculate final price using addition
Print the final price
💡 Why This Matters
🌍 Real World
Calculating prices, discounts, and taxes is common in retail and billing systems.
💼 Career
Understanding arithmetic operators helps automate calculations in scripts for finance, sales, and inventory management.
Progress0 / 4 steps
1
Create item price and quantity variables
Create two variables: $price with value 15 and $quantity with value 4.
PowerShell
Need a hint?

Use = to assign values to variables in PowerShell.

2
Add a discount percentage variable
Create a variable called $discountPercent and set it to 10 (which means 10%).
PowerShell
Need a hint?

Remember to use $ before variable names in PowerShell.

3
Calculate total price and discount amount
Calculate the total price before discount by multiplying $price and $quantity and store it in $totalPrice. Then calculate the discount amount by multiplying $totalPrice with $discountPercent divided by 100, and store it in $discountAmount.
PowerShell
Need a hint?

Use * for multiplication and / for division in PowerShell.

4
Calculate final price and print it
Calculate the price after discount by subtracting $discountAmount from $totalPrice and store it in $priceAfterDiscount. Then calculate tax amount as 5% of $priceAfterDiscount and store it in $taxAmount. Finally, calculate the final price by adding $priceAfterDiscount and $taxAmount and store it in $finalPrice. Print the value of $finalPrice.
PowerShell
Need a hint?

Use - for subtraction and + for addition. Use Write-Output to print in PowerShell.