Question
Write a Java console application that reads a string from the keyboard and tests whether it contains a valid date. Display the date and a
Write a Java console application that reads a string from the keyboard and tests whether it contains a valid date. Display the date and a message that indicates whether it is valid. If it is not valid, also display a message explaining why it is NOT valid.
The input date will have the format mm/dd/yyyy. A valid month value mm must be from 1 to 12 (January is 1). You can use:
String monthPart = inputDate.substring(0, 2); int month = Integer.parseInt(monthPart); to get the month value.
A valid day value dd must be from 1 to a value that is appropriate for the given month. September, April, June, and November each have 30 days. Assume February has 28 days. All other months have 31 days. The year can be any 4 digit year.
***Be sure to use a switch statement at least once (perhaps for checking the valid months)***
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started