| Unit3 Home | Unit3 3.1 | Unit3 3.2 | Unit3 3.3 | Unit3 3.4 | Unit3 3.5 | Unit3 3.6 | Unit3 3.7 | Unit3 HW | 
Unit 3 Team Teach - 3.2
Unit 3 Team Teach
3.2 If Statements and Control Flow
popcorn hack
create test cases that do not satisy the condition above. you can copy/paste the code into the new code cell
public static void main(String[] args) {
    int myAge = 16;
    System.out.println("Current age: " + myAge);
    
    if (myAge >= 16) {
        System.out.println("You can start learning to drive!");
    }
    System.out.println("On your next birthday, you will be " + (myAge + 1) + " years old!");
}
public static void main(String[] args) {
    // Test case 1: Age less than 16 (condition -> false)
    int myAge1 = 15;
    System.out.println("Current age: " + myAge1);
    
    if (myAge1 >= 16) {
        System.out.println("You can start learning to drive!");
    } else {
        System.out.println("You cannot start learning to drive yet.");
    }
    System.out.println("On your next birthday, you will be " + (myAge1 + 1) + " years old!\n");
    
    // Test case 2: Age far less than 16 (condition -> false)
    int myAge2 = 10;
    System.out.println("Current age: " + myAge2);
    
    if (myAge2 >= 16) {
        System.out.println("You can start learning to drive!");
    } else {
        System.out.println("You cannot start learning to drive yet.");
    }
    System.out.println("On your next birthday, you will be " + (myAge2 + 1) + " years old!\n");
    
    // Test case 3: Age equal to 16 (condition -> true)
    int myAge3 = 16;
    System.out.println("Current age: " + myAge3);
    
    if (myAge3 >= 16) {
        System.out.println("You can start learning to drive! (Condition -> true)");
    } else {
        System.out.println("You cannot start learning to drive yet.");
    }
    System.out.println("On your next birthday, you will be " + (myAge3 + 1) + " years old!");
}
If statements can be used to create chatbots 
–> Magpie Lab
- the user’s input affects the flow of the program