Determine Output 1 (5 points) Let the classes A and B be class A { int i; A () { i = 3; } void doubled () { i *= 2; } } class B { A a; B (A a) { this.a = a; } void put (A a) { this.a = a; } } Further we have a program with the following statements/declarations A a1 = new A(); B b1 = new B(a1); PrintStream out = new PrintStream(System.out); void print (A x, B y) { out.printf("%d %d\n", x.i, y.a.i); } void doSomething () { print(a1, b1); b1.a.doubled(); print(a1, b1); A a2 = new A(); print(a2, b1); b1.put(a2); print(a2, b1); B b2 = new B(a1); print(a1, b1); b2.a.doubled(); print(a2, b2); b1.a.doubled(); b2.put(b1.a); print(a2, b2); } What will be printed when the method doSomething() is called? Determine Output 2 (5 points) import java.io.PrintStream; class DetermineOutput2 { PrintStream out; int a, b; DetermineOutput2 () { a = 4; b = 5; out = new PrintStream(System.out); } void print (int a, int b) { out.printf("%d %d\n", a, b); } int methode1(int b) { a = a + b; b = a / b; print(a, b); return a; } int methode2 (int b, int c) { int a = b - 3; c = this.a - c; b = methode1(c); print(c, a); return b; } void start() { print(a, b); a = methode1(b); print(a, b); b = methode2(a, b); print(a, b); } public static void main(String argv[]) { new DetermineOutput2().start(); } } Assignment 2a (4 points) The method sumTerms() should calculate the sum of the first n terms of the series: (1/3)*x^2 - (1/4)*x^3 + (1/5)*x^4 - (1/6)*x^5 + (1/7)*x^6 - ..... x^n is the notation for "x to the power n". Implement this method without using any methods from the class Math. IMPORTANT Assume: n >= 1 public static double sumTerms (int x, int n) { // implementation still to be added } Assignment 2b (5 points) Program a method numberOfTops() that will be able to calculate, for any matrix of int's, how many tops there are in this matrix. For this problem a top is defined as a number that is not only bigger than the prior number, but also bigger than the next number. If a number does not have a prior number or no next number, than this number is not a top. Example: 1 2 1 2 1 This matrix has three tops, 3 3 3 3 3 the two 2's in the first row 1 2 9 3 8 and the 9 in the third row. 9 2 2 2 9 No tops in this matrix. 9 1 1 1 9 9 0 0 0 9 public static int numberOfTops (int[][] m) { // implementation still to be added } Assignment 3a (4 points) 4 points Implement the method expensive() in the class Street. This method should return false if the average price of the houses in the street is less than 350000 euro's and true if this is not the case. class House { int numberOfFloors; boolean hasGarden; double price; // in euro's House (int numberOfFloors, boolean hasGarden, double price) { this.numberOfFloors = numberOfFloors; this.hasGarden = hasGarden; this.price = price; } } class Street { static final int MAX_NUMBER_OF_HOUSES = 500; String name; House[] houseArray; int numberOfHouses; Street (String name) { this.name = name; houseArray = new House[MAX_NUMBER_OF_HOUSES]; numberOfHouses = 0; } void add (House house) { houseArray[numberOfHouses] = house; numberOfHouses += 1; } boolean expensive () { // 4 points // implementation still to be added } } class Village { static final int MAX_NUMBER_OF_STREETS = 50; String name; Street[] streetArray; int numberOfStreets; Village (String name) { this.name = name; streetArray = new Street[MAX_NUMBER_OF_STREETS]; numberOfStreets = 0; } void add (Street street) { streetArray[numberOfStreets] = street; numberOfStreets += 1; } } Assignment 3b (6 points) Given is that the class String contains a method String substring (int start) that calculates the substring from the character on index position start till the last character (inclusive). Examples: "abcdef".substring(3) gives "def" "abcdef".substring(0) gives "abcdef" 3 points 1 - Implement the method isLane() in the class Street. This method should return true if the street is a lane. For this problem it is defined that a street is a lane if the name of the street has a minimum length of 5 and ends with "lane". 3 points 2 - Implement the method numberOfLanes() in the class Village. This method should count and return how many of the streets in the village are a lane. // in the class Street boolean isLane () { // 3 points // implementation still to be added } // in the class Village int numberOfLanes () { // implementation still to be added } Assignment 3c (8 points) 2 points 1 - Implement the method isBig() in the class House. This method should return true if the house is big. For this problem it is defined that a house is big if it has more than 1 floor and also has a garden. 3 points 2 - Implement the method majorityBig() in the class Street. This method should return true if the majority (> 50.0%) of the houses in the street are big houses. 3 points 3 - Implement the method bigHouses() in the class Village. This method should return, in a new Village object, all the streets where the majority of the house are big houses. The name of the new The name of the new village should be "big". // in the class House boolean isBig () { // 2 points // implementation still to be added } // in the class Street boolean majorityBig () { // 3 points // implementation still to be added } // in the class Village Village bigHouses () { // 3 points // implementation still to be added } Assignment 4a (4 points) Write a recursive implementation for the method print() that will print the following rows of symbols. print(1) -> (a) print(2) -> (aa(a)aa) print(3) -> (aaa(aa(a)aa)aaa) print(4) -> (aaaa(aaa(aa(a)aa)aaa)aaaa) If you want to print 1 character "c" or a string s, use the command System.out.print(c) or System.out.print(s). // the method below can be used to print n times the character c public static void print (char c, int n) { for (int i = 0; i < n; i++) { System.out.print(c); } } IMPORTANT: assume n >= 1 public static void print (int n) { // implementation still to be added } Assignment 4b (4 points) Given is that the class String contains a method String substring (int start) that calculates the substring from the character on index position start till the last character (inclusive). Examples: "abcdef".substring(3) gives "def" "abcdef".substring(0) gives "abcdef" Write a recursive method dashes() that will compute and return a new string where all the adjacent chars are now separated by a "-". Examples: dashes("") returns "" dashes("a") returns "a" dashes("ab") returns "a-b" dashes("abc") returns "a-b-c" dashes("abcd") returns "a-b-c-d" public static String dashes (String s) { // implementation still to be added }