Educational Objective
This LA will give us some experience working with getting input from the user and displaying information to the user.
Instructions
In a nutshell, the program you write will ask the user for three pieces of information: first name, last name, and age. The script will then echo this information back to the user.
There are three versions of this lab: minus, check, and plus. They are essentially enhancements of each other. Do not submit different versions of the program for the different levels.
General Requirements for the Learning Activity
The Java source code file shall start out with an initial comment block.
The first lines of the comment block shall include your first and last name, the name and number of the LA, and the level you want the lab graded at. The level is minus, check, or plus, as described below.
It is desirable that the initial comment block include a short description of the purpose of the program. This becomes a requirement for the plus level.
The source code shall contain other comments explaining what's going on.
The comments shall precede the sections of code the associated code.
For this LA, it can be minimal. two comments: "gathering information from the user" and "echoing information back to the user" or the like.
Minus Version
In the minus version, the program shall ask the user three questions. The first question shall ask the user's first name. The second question shall ask the user's last name. The third question shall ask the user's age. It will then greet the user by name, first and last, then echo (repeat) the user's current age, and calculate and report the user's age next year.
Here is an example of what the minus version will do. The user input is shown in bold.
What is your first name? Fred
What is your last name? Farkle
What is your age? 63
It's nice to meet you, Fred Farkle.
This year, you're 63 years old.
Next year, you'll be 64.
Notes for the minus version
Notice that the first name and the last name are strings. The age is a number. (What does this tell you about how you need to ask for the input? (This is a rhetorical question, not participation fodder.)
Just accept whatever the user types for the first name and the last name. Assume that the user will type in a whole number (integer) for age. (We don't know how to handle user input errors … at least not yet. So, if the user types in something that is not an integer, it's ok if the program crashes.)
When you echo the information, print the information out in full sentences. Please use exactly the sentences shown in the example. You will have opportunities to be creative later in the semester. (Notice the apostrophes in the sentences for the minus version. The check and plus versions have both apostrophes and quotation marks.)
To calculate the user's age next year, you'll need to add one to it. That's why it has to be a number.
Check Version
The check version is an enhanced version of the minus version. In the check version, you need to report the age both in human years and in "dog years".
Here is an example:
What is your first name? Susie
What is your last name? Smith
What is your age? 7
It's nice to meet you, Susie Smith.
This year, you're 7 years old.
That's 49, in "dog years".
Next year, you'll be 8, or 56 in "dog years".
Notes for the check version
All the notes for the minus version still apply.
Please use exactly the sentences shown in the example. Notice that these sentences have both apostrophes and quotation marks in them.
To calculate "dog years", simply multiply the age by 7. (Another reason why age has to be a number.)
Plus Version
multiple word names: Edgar Allen Poe, Martin Van Buren
The plus version is an enhanced version of the check version. The plus version includes several enhancements:
multiple word names
output initials
enhanced the initial comment block
This is work done in addition to the Check level work.
Multiple Word Names
Some names are typically given with two or more pieces (words) for the first name or last name. Examples include: Edgar Allan Poe and Martin Van Buren. [fodder: Who are these individuals? Share. Answer only one.] Make sure that your program handles these names correctly.
Also, clean up the first and last name by removing leading and trailing spaces.
Initials
Update the program to include a line printing the initials of the individual. For this task, it is sufficient to print the first non-blank character of the first name and the first non-blank character of the last name. So, for "Edgar Allan Poe", the initials "EP" are sufficient. Extra kudos for "EAP", but not extra points.
Initial Comment Block
Add a brief description of the program in the initial comment block. A simple statement of the obvious actions/purpose of the program is sufficient.
Sample Run
Here is an example of the output:
What is your first name? Chris L
What is your last name? Park jr
What is your age? 12
It's nice to meet you, Chris L Park jr.
Your initials are CP.
This year, you're 12 years old.
That's 84, in "dog years".
Next year, you'll be 13, or 91 in "dog years".
Submission
The Java source code file (.java).
Grading Rubric
Minus:
The script runs: asks three questions and prints out the name and age information as described in the write-up
Check:
Minus functionality, plus adding information about age in "dog years". Conforms to homework guidelines.
If the output text (echoing information to the user) does not match what is in the write-up, the submission will receive a minus. This includes both punctuation and spaces.
Plus:
Check functionality, plus support for multiple word names, output of initials, and (slightly) more detailed commenting.
AIMING FOR THE PLUS VERSION