1. Expression Value ------------------------------------------------- 16 / 3 + 3.2 * 2 11.4 8 / 7 + "5/4" + 8 / 3 "15/42" 88 % 10 % 3 * 16 / 10 3 29 / 3 / 2 / 4.0 + 3.6 * 2 8.2 1.4 + (3 + 2 * 6) / (8 - 14 / 3) * 2.2 8.0 2. Parameter Mystery. The program produces the following output. foo wants buzz to sue. bill wants sue to buzz. hope wants foo to bill. hope wants bill to sue. 3. Method Call Output Produced --------------------------------------- ifElseMystery(1, 8); 3 8 ifElseMystery(3, 5); 5 0 ifElseMystery(4, 5); 5 6 ifElseMystery(8, 6); 8 2 ifElseMystery(7, 7); 7 8 ifElseMystery(5, 7); 7 2 4. Method Call Output Produced --------------------------------------- mystery(8); 1 8 mystery(32); 2 5 mystery(72); 2 9 mystery(184); 3 13 mystery(8239); 4 22 5. next == 0 prev == 0 next == prev +---------------------+---------------------+---------------------+ Point A | sometimes | always | sometimes | +---------------------+---------------------+---------------------+ Point B | never | sometimes | sometimes | +---------------------+---------------------+---------------------+ Point C | never | never | always | +---------------------+---------------------+---------------------+ Point D | sometimes | never | sometimes | +---------------------+---------------------+---------------------+ Point E | always | sometimes | sometimes | +---------------------+---------------------+---------------------+ 6. Programming. One possible solution appears below: public static void randomCone(int n) { Random r = new Random(); int height = r.nextInt(n) + 1; for (int line = 1; line <= height; line++) { for (int space = 1; space <= 2 * line - 2; space++) { System.out.print(" "); } System.out.print("V"); for (int j = 1; j <= height - line; j++) { System.out.print("---V"); } System.out.println(); } } 7. Programming. One possible solution appear below: public static boolean hasOddEvenDigit2(int n) { int evens = 0; int odds = 0; while (n > 0) { if (n % 2 == 0) { evens++; } else { odds++; } n = n / 10; } return evens > 0 && odds > 0; } 8. Programming. One possible solution appear below: public static int numWords(String s) { int count = 0; boolean inWord = false; for (int i = 0; i < s.length(); i++) if (s.charAt(i) == ' ') inWord = false; else if (!inWord) { count++; inWord = true; } return count; }