CS 1401, Quiz #3

Date: Tuesday, February 1, 2005
Name (please type legibly, ideally in block letters): ______________________________________________________________________
UTEP ID # (if you do not remember it, it is OK): ______________________________________________________________________

1. Let us assume that we have already defined an input object in as

BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
Write a main method that asks a user for name of his or her favorite pet, and then prints a message
Your favorite pet was (this name).
For example, if your favorite pet was a pony called Little Seabiscuit, then the computer should print the following message:
Your favorite pet was Little Seabiscuit.
Do not forget that the header of the main method is:
public static void main(String[] args) throws IOException





























(Turn over, please).

2. Suppose that you already have variables start and end that describe the times when the class starts and when the class ends. Write a statement (piece of Java code) that would define a new variable duration and assigns to it the value end - start.