University of Toronto -- Department of Computer Science CSC 108S - Spring 1998 Midterm test (Clarke's section) Aids allowed: Textbook only. Time: 50 minutes 1. [10 marks] Write a complete program to read a sequence of strings, stopping when the input string is "XXX". The program's output is the string with the most J's in it. Only upper-case J's count. You must not use an array. Here is an example of input and the corresponding output: input: Java output: Jumping jellybeans, said Jim. Jumping jellybeans, said Jim. XXX 2. [10 marks] (a) Write a class "Prof" representing professors. Each professor has two attributes: name (a String) and age (an int). Write the fields and methods in the spaces below. (You can also use the back of a page, if necessary.) i. The class header and the fields (data members). The fields must be private. ii. A constructor that takes two parameters: name and age. iii. A comparison method "olderThan" that returns true or false depending on whether the Prof object the method belongs to has a greater age than another Prof object. The one parameter of the method is the other Prof. iv. Any other methods that you may need to write for the Prof class in order to complete part (b). (b) Now write a fragment of a "main" method that declares two Prof variables and initializes them with names and ages read from the input. Then your program must compare the ages of the two Profs using the olderThan method, and print a message saying which of the two Profs is older. You can assume that an input stream "stdin" has already been set up for you. If the Profs have the same age, your program is allowed to say (wrongly) that one of them is older. Here is an example of input and output: input: Isaac output: Isaac is older than Albert 60 Albert 45