Session 6: Introduction to Decision Making
Your Name
- 6 minutes read - 1193 wordsSession 6: Introduction to Decision Making
Learn conditional statements and decision making. Create programs that respond differently to user input.
🎯 Key Skills You'll Learn:
- if, else if, else statements
- Comparison operators
- Logical operators
- Boolean logic
🚀 Session Project:
Rock, Paper, Scissors Game
Learning Objectives
- Understand conditional statements and decision making
- Learn the
if,else if, andelsestatements - Create programs that respond differently to user input
- Understand boolean logic and comparisons
Warm-up (10 minutes)
Think about decisions you make every day:
- If it’s raining, I bring an umbrella
- If I’m hungry, I eat food
- If it’s weekend, I sleep in
How would you teach a computer to make these same decisions?
New Concept Introduction (30 minutes)
What are Conditional Statements?
Conditional statements let programs make decisions based on different situations. Just like you decide what to wear based on the weather, programs can decide what to do based on user input or calculations.
Basic if Statement
|
|
if-else Statement
|
|
if-else if-else Chain
|
|
Comparison Operators
|
|
Important: = vs ==
|
|
Logical Operators
|
|
Hands-on Practice (40 minutes)
Exercise 1: Simple Password Checker (15 minutes)
|
|
Exercise 2: Number Guessing Game (15 minutes)
|
|
Exercise 3: Grade Calculator with Feedback (10 minutes)
|
|
Challenge/Quiz (10 minutes)
Challenge: Rock, Paper, Scissors Game Create a program that:
- Asks the user to enter their choice (rock, paper, or scissors)
- The computer randomly chooses (for now, just pick one - we’ll learn random later)
- Determines the winner based on the rules:
- Rock beats Scissors
- Scissors beats Paper
- Paper beats Rock
- Same choices = Tie
- Displays both choices and announces the winner
Validation Prompt
🤖 AI Validation Prompt
Copy this prompt and your code to ChatGPT or Claude for instant feedback:
```
I'm learning C++ and just completed Session 6. Here's my solution to the Rock, Paper, Scissors challenge:
[PASTE YOUR CODE HERE]
The challenge was: Create a Rock, Paper, Scissors game that compares user input with a computer choice and determines the winner.
Please check if my solution:
1. Uses if-else statements correctly
2. Implements the game rules properly
3. Handles string comparisons correctly
4. Displays clear output showing both choices and the result
5. Uses logical operators appropriately
If there are issues, please explain what's wrong and give me a hint to fix it (don't give me the complete solution).
```
What You Learned
- ✅ If, else if, and else statements
- ✅ Comparison operators (==, !=, <, >, <=, >=)
- ✅ Logical operators (&&, ||, !)
- ✅ Boolean logic and decision making
- ✅ Creating interactive programs that respond to input
Next Session Preview
In Session 7, you’ll learn about nested conditions and more complex decision-making scenarios!