• Home
  • Reviews
  • Articles
  • News
  • Tools
  • GamingHeaven
  • Forums
  • Network
 

Go Back   DriverHeaven.net > Forums > Software / Tools > Programming, Coding, (Web)Design

Notices

Reply
 
LinkBack Thread Tools
Old Jun 18, 2007, 06:42 AM   #1
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
Old Nov 23, 2007, 01:31 AM   #2
DriverHeaven Newbie
 
Join Date: Nov 2007
Posts: 5
mario12 is on a distinguished road

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.................
mario12 is offline   Reply With Quote
Old Nov 23, 2007, 02:06 AM   #3
S-3D enthusiast
 
Tril's Avatar
 
Join Date: Sep 2004
Location: Canada
Posts: 1,410
Tril is on a distinguished road
System Specs

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:
Originally Posted by www.codeproject.com/info/faq.asp
  1. Can I use code snippets and programs in my own work? You can use code snippets and source code downloads in your applications as long as
    • You keep all copyright notices in the code intact.
    • You do not sell or republish the code or it's associated article without the author's written agreement
    • You agree the code is provided as-is without any implied or express warranty.
    Some authors may also have specific restrictions on using code in commercial apps such as providing credit in documentation or sending them an email first.
Tril is offline   Reply With Quote
 

 
Powered by: vBulletin
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Artwork by Allan 'Zardon' Campbell, vBulletin implementation by Craig '5320' Humphreys based on original artwork by Ratchet.

All times are GMT -5. The time now is 06:31 PM. Copyright ©2008 HeavenMedia.net