A02

Due Date: Friday, September 22
File(s) to be submitted: YearCalculator.java
Sample Output: SampleOutput.html


SUBMIT   /   Check

Math, Input & Output

Synopsis

For this assignment, you must create a Java application that reads a person's name and the year they were born, and then produces the following output:

  1. A greeting, using their name.
  2. How old they will be at the end of this year (2023).
  3. About what year they can retire (at age 65).
  4. The average length of a generation (27.5 years).
  5. The approximate years their parents and grandparents were born.
  6. A wish for them to say "Hi" to their grandparents.

Details

This assignment is for you to practice input, output and math -- and also using proper style in your programs.

Your program starts by introducing itself. Its introduction should include:

  1. a suitable title, underlined;
  2. a short description of the program's purpose; and
  3. author information -- your name and A-number.
After printing the introduction, the program pauses, waiting for the user to press the enter key.
Hint: How do we tell the computer to read a line of input?

Next your program does input. It prompts for and reads the user's full name (spaces included). Then it prompts for and reads the year they were born.

Hint: How many times does the user press the enter key to do that input?
After reading the user's information, the program pauses again.
Hint: If your program doesn't pause, even tho' you told it to read another line, look back at the hint for reading their name and year of birth. There's something you forgot to do there!

Finally, your program prints out the messages mentioned in the summary. For example, the output might be:

Hi, Mark Young! Since you were born in 1962, you turn 61 this year. You will retire about 2027. Did you know that the average generation is about 27.5 years? That means that your parents were probably born about 1934, and your grandparents about 1907. Say "Hi" to your grandparents from me the next time you see them!

Further requirements:

  1. The length of a generation must be printed as a double.
  2. The years must all be printed as integers -- even the (approximate) birth years of parents & grandparents.
  3. Your parents were born one generation before you; your grandparents two generations before you.
  4. You must use variables for the current year, the age of retirement, and the length of a generation. The output must still be correct if I change the value of one of those variables.
    For example, if I change the current year variable to be 2024, then the age should be the age the person will turn next year. If I change the generation length to 30.0 years, then the output should say that it's 30.0 years, and that my parents were born about 1932, and my grandparents about 1902 -- without any other changes to the code.
  5. There must be blank lines in the output separating the output into four logical chunks:
  6. And while that is all your program must do, keep in mind that it must still satisfy the standard requirements for assignments. In particular, that means:

Grading Outline

Note: There will be penalties for submissions that do not compile (that Netbeans shows with those red squiggly underlines) or that "crash" on sample input (do input in an unexpected way). The grader may assign a grade of zero if they deem the code too hard to fix.
SUBMIT   /   Check