 Pure Programmer ## Project: Ordinal Date (Revisited)

Write a function to compute the ordinal date. The function should have arguments for month, day and year. Write a second function to determine if the year is a leap year that is used by the first function. Use preconditions to validate the function arguments and postconditions to check the result. You can compute the ordinal date with the following formula:

• for January: d
• for February: d + 31
• for the other months: the ordinal date from March 1 plus 59, or 60 in a leap year
• where the ordinal date from March 1 is: floor(30.6m-91.4)+d

and a year is a leap year if it is evenly divisible by 4 but not evenly divisible by 100 unless it is evenly divisible by 400.

See [[Ordinal Date]] and [[Leap Year]]

Output
\$ g++ -std=c++17 OrdinalDate2.cpp -o OrdinalDate2 -lfmt \$ ./OrdinalDate2 2 22 1732 2/22/1732 = 53 Ordinal Date \$ g++ -std=c++17 OrdinalDate2.cpp -o OrdinalDate2 -lfmt \$ ./OrdinalDate2 3 1 1900 3/1/1900 = 60 Ordinal Date \$ g++ -std=c++17 OrdinalDate2.cpp -o OrdinalDate2 -lfmt \$ ./OrdinalDate2 3 26 1963 3/26/1963 = 85 Ordinal Date \$ g++ -std=c++17 OrdinalDate2.cpp -o OrdinalDate2 -lfmt \$ ./OrdinalDate2 8 5 1993 8/5/1993 = 217 Ordinal Date \$ g++ -std=c++17 OrdinalDate2.cpp -o OrdinalDate2 -lfmt \$ ./OrdinalDate2 3 1 2000 3/1/2000 = 61 Ordinal Date

Solution