1. Expressions: 1. 13 2. "84 + 217" 3. -0.5 4. true 5. 6 2. Parameter Mystery: picnic and lemonade like ants ants and ants like y lemonadey and antspicnic like antsy lemonade and sunny like today 3. if/else simulation: ifElseMystery(5, 20): 7 5 ifElseMystery(42, 42): 43 41 ifElseMystery(6, 1): 9 7 ifElseMystery(2, 0): 3 -1 4. While Mystery: whileMystery(7, 5): 4 3 1 whileMystery(20, 4): 16 13 11 10 10 whileMystery(40, 10): 30 21 13 6 5 5 whileMystery(2, 2): 1 1 5. Assertions: x % 2 == 0 y > x y % 2 == 1 point A S S N point B S A S point C A A N point D A A N point E S N S 6. randomSquare public static int randomSquare(int size) { Random r = new Random(); int count = 0; for (int i = 0; i < size; i++) { int backslashes = r.nextInt(size + 1); count += backslashes; for (int j = 0; j < backslashes; j++) { System.out.print("\\"); } for (int j = 0; j < size - backslashes; j++) { System.out.print("/"); } System.out.println(); } return count; } 7. eights public static void eights(Random r, int n) { int count = 0; while (count < n) { int result = r.nextInt(2) + 7; System.out.print(result); if (result == 8) { count++; } else { count = 0; } if (count < n) { System.out.print(", "); } } System.out.println(); } public static void eights(Random r, int n) { int result = r.nextInt(2) + 7; System.out.print(result); int count; if (result == 8) { count = 1; } else { count = 0; } while (count < n) { result = r.nextInt(2) + 7; System.out.print(", " + result); if (result == 8) { count++; } else { count = 0; } } System.out.println(); } 8. hasAlternatingParity public static boolean hasAlternatingParity(int n) { int last = n % 10; n = n / 10; while (n > 0) { int digit = n % 10; if (last % 2 == digit % 2) { return false; } last = digit; n = n / 10; } return true; }