Summer, 2004: Section 1
Due: Tuesday, 5/25 /04
1. Write a JAVA program that allows the user to enter
two names and for each name, one 8-digit integer representing the person's date
of birth. Use a Java input dialog box for
each data entry. For example, the first name could be Sally
with a date of birth of 19840130. We can
assume that the user enters good data with 8 digits for each birthday so you
do not have to do any error-testing.
2. The program should separate each 8-digit number into three separate numbers
to represent the year, month, and day, in that order.
- Thus in our example the program would assign 1984
to the first number variable, let's say year1 and
then assign 1 to a second variable, let's say
month1 and last should assign 30
to a third variable called day1.
Then the program would assign the year, month, and day to the other date
using variables such as year2, month2, and
3. Next the program should print out both names, each followed by their date
of birth written in the following standard format and displayed in an output
window. Do not worry about leading zeroes for days and months. For example:
4. Next the program should determine who is the oldest by
testing the value of the numbers and
then printing out his/her name as follows, again in a display window:
- Sally was born on 1/30/1984.
- Patty was born on 11/28/1985.
- Sally is older than Patty!
If the two people were born on the same day, then the message should read:
- Sally and Patty are the same age!
Hint: Use the % and /
operators and Integer Numbers.
When you are done and have tested it, email your source file "asg1.java"
as an attachment to the course grader account at firstname.lastname@example.org
In the subject field of your email, please write yourfirstname_lastname_assignment#.
Notes about your program:
- Make sure your program includes a comment at the beginning listing your
personal info (name and section) along with a brief synopsis of the program's
- You should use comments throughout the source code to explain key steps
- Choose intuitive names for variables
- You should use proper indentation and blank lines to make your program
easy to read