Question 17:

String str = "a black cat sat on a table";

int counter = 0;

for (int i = 0; i < str.length() - 1; i++) {

    if (str.substring(i, i + 1).equals("a") && !str.substring(i + 1, i + 2).equals("b")){
        counter++;
    }
}

System.out.println(counter);
5
int[] nums = {7, 10, 10, 15, 15, 15, 15, 10, 10, 10, 15, 10, 10};

public int findLongest(int target)
{
    int lenCount = 0;
    int maxLen = 0;

    for (int val : nums){
        if (val == target) {
            lenCount++;
        }
        else {
            if (lenCount > maxLen){
            maxLen = lenCount;
            }
            lenCount = 0;
        }
        }
    if (lenCount > maxLen){
        maxLen = lenCount;
    }
    return maxLen;
}

System.out.println(findLongest(10));
3
System.out.print("I do not fear computers. ");   // Line 1

System.out.println("I fear the lack of them.");
System.out.println("I fear the lack of them.");   // Line 2

System.out.println("--Isaac Asimov");            // Line 3
I do not fear computers. 
I fear the lack of them.
I fear the lack of them.
--Isaac Asimov
System.out.print("*");     // Line 1
System.out.print("*");   // Line 2

System.out.println();    // Line 3

System.out.println("*"); // Line 4
**
*
System.out.print("One");   // Line 1

System.out.println("Two");   // Line 2

System.out.print("Three"); // Line 3

System.out.print("Four");  // Line 4
OneTwo
ThreeFour