Pure Programmer
Blue Matrix


Cluster Map

Project: Ordinal Date

Write a function to compute the ordinal date. The function should have arguments for month, day and year. Use preconditions to validate the function arguments and postconditions to check the result. There are two different ways to compute the ordinal date. One is to directly compute it using min() and max() (See [[Ordinal date]]). The other is to precompute the days prior to the beggining of a month and store the results in an array.

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

Solution