Question: Write a program that reads a String from the keyboard and tests whether it contains a valid date. Display the date and a message that
Write a program that reads a String from the keyboard and tests whether it contains a valid date. Display the date and a message that indicates whether the date is valid or not valid. If the date is not valid, also display a message why the date is not valid (ie, 2/29/1900 is not valid. cannot have 29 days in a non-leap year). The input date will have the format mm/dd/yyyy. In Java using java.util.Scanner please with explanation of code. I've also attached the input and correct outputs.
1) 2/29/2000 is a valid date. 2) 2/29/1900 is not a valid date. Cannot have 29 or more days in a non-leap year. 3) 2/29/2020 is a valid date. 4) 4/31/2021 is not a valid date. Cannot have 31 days in this month. 5) 4/15/2021 is a valid date. 6) 7/25/2021 is a valid date. 7) 5/32/2013 is not a valid date. Cannot have more than 31 days in any month. 8) 13/13/2013 is not a valid date. Months must be 1 to 12.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
