Computer Science 121
Assignment 2
Due: February 5, 2003

Your second assignment is to write a program that displays the ages of two people.  Each should be a separate instance of the class that stores information about them.  The data for each should be the name and the year that the person was born.  For the purposes of this program, assume that the person was born on the first day of the year, so that if he or she were born in 1990, he or she would be 13 = 2003 – 1990.  This computation can be done in either the constructor or the displayAge method.  You may assume that the current year is 2003.

Hand in a print out of your program and a disk containing both the .java and the .class files.  In addition, write a separate paper that answers the questions given below.  Type your paper using an appropriate word processor, such as Word or WordPerfect.

Questions

1. How did you choose the names (identifiers) that you used in your program?

2. What would happen if you changed the order of some of the statements in the main method?  For example, what would the output be if you tried to display the age before you got a new instance of the Person class?

3. What would you have to know in order to calculate the actual age of the person?  Most people are not born on January 1.

4. How would you change your program to display the year when the person will be 21?