Solution to
Try It Yourself: loops

  1.  
    1. Loops 1, 2, 5, 6
    2. Loops 3, 4
    3. Loops 3, 4, 6
    4. Loop 4
    5. Loops 1, 2, 4, 6
    6. Loops 3, 5


  2.  
    one
    two
    two
    zero
    three
    


  3.  
    int input;
    do {
      input = Integer.parseInt(stdin.nextLine());
    } while ((input % 4 != 0) && (input % 7 != 0));
    


  4.  
    // first print the top row
    for (int i = 0; i < col; i++)
        System.out.print("*");
    System.out.println();
       
    // print the middle
    for (int r = 1; r < row - 1; r++) {
        System.out.print("*");
        for (int c = 1; c < col - 1; c++)
            System.out.print(" ");
        System.out.println("*");
    }
    
    // print the last row
    for (int i = 0; i < col; i++)
        System.out.print("*");
    System.out.println();
    


  5.  
    public static int countLower(String str) {
        int count = 0;
        for (int i = 0; i < str.length(); i++) {
            char ch = str.charAt(i);
            if ('a' <= ch && ch <= 'z')
                count++;
        }
        return count;
    }