|
|||||||
| Programming, Coding, (Web)Design Discuss all your programming or design needs with likeminded people. |
![]() |
|
|
Thread Tools |
|
|
#1 |
|
DriverHeaven Newbie
Join Date: Apr 2007
Posts: 5
Rep Power: 0 ![]() |
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 |
|
|
|
|
|
#2 |
|
DriverHeaven Newbie
Join Date: Nov 2007
Posts: 5
Rep Power: 0 ![]() |
Hi friend...
For getting the solution of your problem, You easily go to Google search engine and type the Keyword C++ classes tutorial. In that you can easily get the solution.................
__________________
I love driverheaven. |
|
|
|
|
|
#3 | |
|
S-3D enthusiast
|
If this for an homework, I would say to think about it and figure it out yourself.
If it's not for an homework, I would say not to reinvent the wheel. Look for free code programmed by others. You'll save time and it's likely that this other person put much more time and effort than you would have put into it yourself. My favorite place to look for such code is The Code Project - Free Source Code and Tutorials. I suggest to do a search on some keywords like "business days". Sometimes, you'll find libraries that can be compiled and used as a dll in your code and other times you'll find classes that can be included and used in your code and other times only some test code. The code won't necessary be in the language you want. It can be C++, C# and it can use .NET or not. You will alsmost always find something that could help you. Respect the copyrights of the code you use. Here's a quote from the website about it : Quote:
|
|
|
|
|
![]() |
| Thread Tools | |
|
|