1. Expression Value 8 + 5 * 3 / 2 15 1.5 * 4 * 7 / 8 + 3.4 8.65 73 % 10 - 6 % 10 + 28 % 3 -2 4 + 1 + 9 + "." + (-3 + 10) + 11 / 3 "14.73" 3 / 14 / 7 / (1.0 * 2) + 10 / 6 1.0 2. happy and pumpkin were orange! orange and happy were pumpkin! orange and sleepy were y! pumpkin and x were green! green and pumpkin were vampire! 3. Method Call Returns mystery(2, 9) 0 mystery(5, 1) 6 mystery(38, 5) 119 mystery(5, 5) 0 mystery(40, 10) 57 4. next < 0 y > z y == 0 +---------------------+---------------------+---------------------+ Point A | sometimes | never | always | +---------------------+---------------------+---------------------+ Point B | never | sometimes | sometimes | +---------------------+---------------------+---------------------+ Point C | never | always | never | +---------------------+---------------------+---------------------+ Point D | sometimes | sometimes | never | +---------------------+---------------------+---------------------+ Point E | always | sometimes | sometimes | +---------------------+---------------------+---------------------+ 5. One solution is shown. public static int numDays(int month) { if (month == 2) { return 28; } else if (month == 4 || month == 6 || month == 9 || month == 11) { return 30; } else { return 31; } } 6. One solution is shown. public static void threeHeads() { Random r = new Random(); int numHeads = 0; while (numHeads < 3) { int flip = r.nextInt(2); // flip coin if (flip == 0) { // heads numHeads++; System.out.print("H "); } else { numHeads = 0; System.out.print("T "); } } System.out.println(); System.out.println("Three heads in a row!"); } 7. One solution is shown. public static int numTWords(String s) { int count = 0; int i = 0; while (i < s.length()) { while (i < s.length() && s.charAt(i) == ' ') // skip over whitespace i++; if (i < s.length()) { if (s.charAt(i) == 't' || s.charAt(i) == 'T') { count++; } while (i < s.length() && s.charAt(i) != ' ') // skip until find next whitespace i++; } } return count; }