String comparison and equality
📖 Scenario: Imagine you are creating a simple program that checks if a user's input matches a secret password. This is a common task in many applications like login screens or secret codes.
🎯 Goal: You will build a program that stores a secret password, takes a user input as a string, compares the input with the secret password using string equality, and then prints whether the input matches or not.
📋 What You'll Learn
Create a string variable called
secretPassword with the exact value "OpenSesame".Create a string variable called
userInput with the exact value "opensesame".Use a boolean variable called
isMatch to store the result of comparing userInput and secretPassword using string.Equals with case sensitivity.Print
"Passwords match!" if isMatch is true, otherwise print "Passwords do not match.".💡 Why This Matters
🌍 Real World
Checking if a user input matches a stored password or code is a common task in login systems, games, and secure applications.
💼 Career
Understanding string comparison is essential for software developers working on authentication, data validation, and user input handling.
Progress0 / 4 steps