Question: Task 3 : ValidDate ( ) Write a method called ValidDate that checks if a date is valid after the first Millennium ( the year

Task 3: ValidDate ()
Write a method called ValidDate that checks if a date is valid after the first Millennium (the year 1000). The method takes three integers for the day, month, and year of the date. It should return true if the date is valid; false otherwise.
A valid month can be indicated with a Boolean monthValid, set to true, if the month entered is between 1 and 12, inclusive.
A valid year can be indicated with a Boolean yearValid, set to true if the year is greater than 1000 inclusive.
If that year is a leap year, you can set a Boolean isLeapYear to true; false otherwise.
The leap year rule says that it's a leap year if
a) it's divisible by 400, or b) it's divisible by 4 and it's not divisible by 100. So 1600 and 1512 are leap years, but 1700 and 1514 are not.
A valid day can be indicated with a Boolean dayValid set to true if the day is valid; false otherwise. A valid day is one that is less than or equal to the number of days in the given month:
You can first determine the number of days in the month entered (30, or 31) and stores that value in a variable daysInMonth. If the month entered is not valid, daysInMonth should get 0. Note that to figure out the number of days in February (280r 29), you'll need to check if it's a leap year.
If the month, day, and year entered are all valid, return true otherwise, return false.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!