Question: Code using dr.java Objective: Write a program that checks whether or not a date entered in by the user is valid. whether or not it
Objective: Write a program that checks whether or not a date entered in by the user is valid. whether or not it is valid. Display the date and tell The input has to be in the format mm/dd . A valid month (mm) must be from 1 to 12 . A valid day (dd) must be from 1 to the appropriate number of days in the month o April, June, September, and November have 30 days o February has at most 29 days o The rest have 31 Example Dialog: Enter a date in the format month/day 6/22 6/22 is a valid date! Another Example Dialog: Enter a date in the format month/day 9/31 9/31 is NOT a valid date! Big Hints: Take in the date as a string and then use the location of the to create substrings and then parse those strings into a numbers to then be checked. .This can be done in a single if-else statement. The trick is making it into a compound statement. If month is January, or the month is March, or the month is May or And the day is between 1 and 31 or the month is April or the month is June or the month is September... and the day is between 1 and 30 then it is valid or if the month is February and the day is between 1 and 29 then it is valid
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
