CIS 35A: Introduction to Java Programming

Home | Green Sheet | Lectures | Assignments | FAQ | Grades | Students

Lab #11 (Exercise 12-2)

Calculate the user's age

Due Date: Wednesday of Week 4
10 points

In this lab, you'll write a program that accepts a person's birth date from the console and displays the person's age in years. To make that easier to do, we'll give you a class that contains the code for accepting the birth date. The console output for the program should look something like this:

  1. Open the AgeCalculatorApp class:
  2. Validator.java

  3. Add code to this class that gets the current date and then uses the current year to validate the birth year the user enters. the user should not be allowed to enter a year after the current year or more than 110 years before the current year.

  4. Add code to create, format, and print the user's birth date and to format and print the current date.

  5. Add code to calculate and print the user's age.

  6. Compile the class. Then run it for a variety of dates to be sure it works.

Include in your program the following comments:
  • Name of program
  • Team's name with all the names of the members (e.g. Team A: John Doe, Jane Smith, etc.)
  • Current Date
  • Computer system and compiler you are using
  • Brief description of the program

Compile and run the Java program.

Take a screen capture by hitting simultaneously the keys Alt and Print Screen (Prt Sc) of the output results (console) and paste it in MS Paint. Save it as a gif file.

When you are ready, upload the java program and the gif file by clicking the link below:

Upload Lab

I cannot grade if I don't get the files and receive your email.