View Single Post
Old Jun 18, 2007, 06:42 AM   #1 (permalink)
berni2k
DriverHeaven Newbie
 
Join Date: Apr 2007
Posts: 6
berni2k is on a distinguished road

C++ Program with Classes

Hi,

How could i code this fast in C++ by using classes:
I want to output the work days between two dates (start and end date input by user).

I thought through it but dont know how to code it.

My thoughts:
1) calculate (count up) the absolute days between the two dates (with using time.h and week modulo)
2) make a class with holidays
3) calculate the holidays with the Gauss easter algorithm (found it on wikipedia and some other site, see bottom of post)
4) substract the holidays from the abolute days
5) cout the absolute days and the count up of holidays and the final work days

Carl Friedrich Gauß (1777 - 1854):

a = Y mod 19
b = Y mod 4
c = Y mod 7
d = (19a + M) mod 30
e = (2b + 4c + 6d + N) mod 7

Y: year with 4 digits

M and N:
for 1583 - 1599 -> M=22, N=2
1600 - 1699 -> 22, 2
1700 - 1799 -> 23, 3
1800 - 1899 -> 23, 4
1900 - 1999 -> 24, 5
2000 - 2099 -> 24, 5
2100 - 2199 -> 24, 6
2200 - 2299 -> 25, 0
2300 - 2399 -> 26, 1
2400 - 2499 -> 25, 1

taking the above easter sunday should be: (22 + d + e).March or (d + e - 9).April
and there are 2 annomalies:
1) if the result of the above falls on the 26th of April -> easter sunday will be held on the 19th of April instead
2) If a > 10 and d = 28 and the result the 25. April, -> easter sunday be corrected to the 18. April.

but how to code this?
HELP

thx a lot
berni2k is offline   Reply With Quote