Selection and Iteration unit test
A test on this unit alone, marked as a percentage and a letter grade — for the test your class is actually sitting, rather than for May. Answer everything, then submit once: seeing the answer to question 3 before attempting question 4 makes the final percentage meaningless.
Counting matches in a loop
Logical OR
Binary search step count
Conditional (ternary) operator
Compound boolean in a loop condition
Standard algorithm: determine if all elements meet a condition
while loop
Counting nested-loop iterations
Choosing while over for
Sequential (linear) search
Standard algorithm: reverse
else if chain
Short answer 1. Define or explain: break
3 ptsShort answer 2. Define or explain: Logical AND
3 ptsShort answer 3. Define or explain: Logical NOT
3 ptsShort answer 4. Define or explain: Empty loop body danger
3 ptsFree response
9 ptsMETHODS AND CONTROL STRUCTURES (Question 1, 9 points). The AccountTools class contains static methods for working with user account information. You will write two of them. public static String initials(String name) — returns a string of the uppercase first letter of each word in name, where words are separated by single spaces and name contains at least one word with no leading or trailing spaces. (For example, initials("ada byron lovelace") returns "ABL"; initials("Grace Hopper") returns "GH"; initials("plato") returns "P".) public static boolean isStrong(String password) — returns true if password satisfies all three of the following, and false otherwise: it is at least 8 characters long; it contains at least one digit ('0' through '9'); and it contains at least one uppercase letter ('A' through 'Z'). (For example, isStrong("Passw0rdX") returns true; isStrong("Password") returns false because it has no digit; isStrong("pass123") returns false because it is too short and has no uppercase letter.) You may use the String methods length(), substring(int), substring(int, int), indexOf(String), equals(String), and toUpperCase().
A. Write method initials. Assume name contains at least one word and that words are separated by single spaces.
B. Write method isStrong.