University of Toronto -- Department of Computer Science CSC 108F - Fall 1998 Midterm test (Bellantoni's 1pm section) Aids allowed: Textbook only. Time: 50 minutes 1. [10 marks] Complete the Java program begun below. It is intended to read one line of input and print every other character, starting with the first character. If the line contains no characters, the program prints nothing. Here is an example of input and the corresponding output: input: Hello, Mary output: Hlo ay And now, the program that you must complete: public class HalfTheCharacters { public static void main (String[] args) throws IOException { BufferedReader in = new BufferedReader (new InputStreamReader (System.in),1); // You write the rest. Don't forget the "}"s ! 2. [10 marks] In this question, you must write part of a "main" method to solve a problem using two classes that you can assume are provided already. Here are the classes that are provided. The contents of the methods are omitted, because you don't need to know how they work. class Person { public int howManyChildren () { ... } // returns an integer that is the number of children the Person has public String getName() { ... } // returns the name of the Person } class PersonReader { public PersonReader (Reader r) { ... } // a constructor -- somewhat like BufferedReader's constructor public Person readPerson() throws IOException { ... } // reads enough input data to make an object of the class Person, // and returns that object. (This is like BufferedReader's // readLine() method, which reads and returns a String.) } Complete the program below. It should read the data about three people, storing each in an object of type Person. Then it should print the name of the Person who has the most children. (If two or more of the Persons have the maximal number of children, then print the name of any one of them.) public class HowManyChildrenOfShortestNamedPerson { public static void main (String[] args) throws IOException { PersonReader in = new PersonReader ( new InputStreamReader (System.in)); // You write the rest. Don't forget the "}"s !