Question: The program should function as follows: Birthdate a. Retrieve birthdate as a string in the format MM/DD/YYYY b. Parse the string to retrieve the month,
The program should function as follows:
Birthdate
a. Retrieve birthdate as a string in the format MM/DD/YYYY
b. Parse the string to retrieve the month, day, year values as integers.
c. Create a GregorianCalendar object the represents the birthdate with these values
Todays date
a. You should NOT query the user for todays date. Use an appropriate system class and methods to determine todays date.
30 Days prior to today
a. Using class libraries, determine the day and date 30 days prior to todays date.
b. Using the regular String class and System.out.print method, print out a sentence telling the day and date 30 days prior as formatted in the example output above.
c. Create a StringBuilder object and use StringBuilder methods to copy the same string, replace the , with a , add single quotes around the date and an ! at the end. d. Print out your StringBuilder object using the System.out.print method.
Current age
a. Using class libraries, determine the users current age.
b. Using the DateFormat class and System.out.printf() method and any other Date, Calendar methods needed, print out a statement formatted as shown in the example output above. The printf() statement should be one statement with the following 3 variables/items included in the one statement:
i. Todays date as a String in LONG format
ii. The Birthdate as a String in LONG format
iii. The current age as an integer
iv. A newline character at the end of the line.
c. Make sure to take into account the birth month vs current month and birth date versus current date!
Retirement date and years
a. Calculate the retirement date, using class library methods, based on the birthdate entered by the user and their desired retirement age.
b. Calculate the number of years until their desired retirement date from todays date.
c. Make sure to take into account the retirement month vs current month and retirement date versus current date! The number of years should be truncated down. (Ex: If its 14 years and 2 months from today the answer should be 14 years. If its 13 years and 11 months the answer should be 13 years.)
d. The retirement information should be printed out using System.out.printf() as shown in the example above. This should be ONE statement that includes the following variables/elements:
i. Retirement date as a string in LONG format
ii. The number of years to retirement as an integer
iii. A newline character at the end of the line
Output:
Enter your birthdate in the format MM/DD/YYYY
03/16/1989
Enter age you plan to retire
65
30 days before today was Saturday, December 23, 2017
30 days before today was 'Saturday - December 23, 2017'!
As of Monday, January 22, 2018, with a birthdate of Friday, February 5, 1971, you are 46 years old.
You will get to retire on Saturday, February 5, 2033, in 16 more years.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
