Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question : Calculate the user's age write an application that gets the user's date of birth. the user's age ... Calculate the user's age write

Question: Calculate the user's age write an application that gets the user's date of birth. the user's age ...

Calculate the user's age write an application that gets the user's date of birth. 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 (mmY-MM-DD) 1968-02-04 Your date of birth is Feb 4, 1968 The current date is Apr 8, 2015 Your age is 47 1. Import the project named ch15 ex2 AgeCalculator that's in the ex starts folder Then. review the code in the AgeCalculatorApp class. package murach.agecalculator; import java.util.Scanner; public class AgeCalculatorApp { public static void main(String[] args) { System.out.println("Welcome to the Age Calculator "); // Get input from the the user Scanner sc = new Scanner(System.in); System.out.print("Enter your date of birth (YYYY-MM-DD): "); String dateOfBirthString = sc.nextLine(); System.out.println(); // Get and print user's date of birth System.out.println("Your date of birth is "); // Get and print the current date System.out.println("The current date is "); //Calculate the user's age //Print the user's age System.out.println("Your age is "); sc.close(); } } 2. Add that string entered by the user to create a code to this class parses the Local object. 3. Add code to format and print the user's date of birth. 4. Add code to format and print the current date. 5. Add code to calculate and print the user's age in years. 6. Run the application and test it to make sure it works correctly for a date in the correct format. 7. 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. 8. Run the application and test it with a date that's after the current date. This date doesn't make sense, but that's OK for now. If necessary, can add data validation code to prevent the user from entering such a date later.

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

Step: 3

blur-text-image

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

Database Design For Mere Mortals

Authors: Michael J Hernandez

4th Edition

978-0136788041

More Books

Students also viewed these Databases questions

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago