Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this exercise, you'll write an application that gets the user's date of birth, calculates the user's age in years, and displays the user's

In this exercise, you'll write an application that gets the user's date of birth, calculates the user's age in years, and displays the user's age. When you're done, the console should look something like this: Welcome to the Age Calculator Enter your date of birth (YYYY-MM-DD): 1968-02-04 Your date of birth is Feb 4, 1968 The current date is Apr 11, 2017 Your age is 49 1. Open the project named ch14_ex2_AgeCalculator that's in the ex_starts folder. Then, review the code in the AgeCalculatorApp class. 2. Add code to this class that gets the current date and stores it in a LocalDate object. 3. Add code that parses the string entered by the user to create a LocalDate object. 4. Add code to format and print the user's date of birth. 5. Add code to format and print the current date. 6. Add code to calculate and print the user's age in years. 7. Run the application and test it to make sure it works correctly for a date in the correct format. 8. Run the application and test it with a date in an invalid format such as "Feb 4, 1968". This should cause an exception to occur. 9. Run the application again, enter a date of birth that's after the current date, and notice that the age is displayed as a negative number. To fix this, validate the date to be sure it isn't after the current date. If it is, display an error message. Run the application one more time to test this change.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Java How To Program Late Objects Version

Authors: Paul Deitel, Deitel & Associates

8th Edition

0136123716, 9780136123712

More Books

Students also viewed these Programming questions

Question

u = $3M, = $0.6M

Answered: 1 week ago