Logical operators
๐ Scenario: You are helping a store manager decide which products to restock based on their sales and stock levels.
๐ฏ Goal: Build a Go program that uses logical operators to find products that need restocking.
๐ What You'll Learn
Create a map called
products with product names as keys and their stock counts as values.Create a map called
sales with product names as keys and their sales counts as values.Create a variable called
restockThreshold to set the minimum stock level before restocking.Use a
for loop with variables product and stock to iterate over products.Inside the loop, use an
if statement with logical operators && and || to check if a product's stock is below restockThreshold or if sales are high.Print the names of products that need restocking.
๐ก Why This Matters
๐ Real World
Stores often need to decide which products to order more of based on current stock and sales trends.
๐ผ Career
Understanding logical operators and data structures like maps is essential for roles in software development, data analysis, and inventory management systems.
Progress0 / 4 steps