Valid Date Project

For the Valid Date Project, you’ll be tasked with creating a Predicate Reporter block. Your block with have to handle three inputs, Day, Month, and Year.  Your block with need to report out <TRUE> or <FALSE> depending on whether or not the Day, Month, and Year are all valid together.  For example, Oct 10th, 1996 is a valid date <TRUE> but Feb 31st, 2013 is not a valid date <FALSE>.  Why? Because there are never 31 days in February.

Some questions/conditions to consider:

Is the “Day” number value within the correct range? What is the correct range? Is it a month with 30 or 3 days? Or 28 vs 29 for Feb?

Is the “Month” number value within the correct range? Is the number between 1-12?

Is the year a leap year? This is the complicated question.

In the Gregorian calendar 3 criteria must be taken into account to identify leap years:

  • The year is evenly divisible by 4;
  • If the year can be evenly divided by 100, it is NOT a leap year, unless;
  • The year is also evenly divisible by 400. Then it is a leap year.

This means that 2000 and 2400 are leap years, while 1800, 1900210022002300 and 2500 are NOT leap years.

The year 2000 was somewhat special as it was the first instance when the third criterion was used in most parts of the world since the transition from the Julian to the Gregorian Calendar.

Please visit this site for more info on Leap Years.

Your first task is to create a FlowChart or use Psudocode to plan out how your block with be structured.  Test your logic before you waste time building it incorrectly.

Advertisements

#projects