November 28th, 2012, 11:46 AM
Join Date: Nov 2012
Time spent in forums: 27 m 36 sec
Reputation Power: 0
Help Writing my first program!
Hello! This is one of the second programs I have been assigned to do, but as a beginner I am a little bit lost on where to start and how to go about creating this program.
The program I have to write is to:
Finding the day of the week corresponding to a specific date.
-It has to read a date
-Compute the corresponding day of the week N using the formula given below
-Output the result (with the day of the week as a word not a number)
I have to use Zeller's congruence equation
h = ( q + (13*(m+1))/5 + K + K/4 + J/4 + 5*J)
- J is the number of the century [i.e. the year / 100],
- K the year within the century [i.e. the year % 100],
- m the month,
- q the day of the month,
Note that in this formula:
- the month indices are: March: 3, April: 4,...but with January being 13 and February being 14.
- January and February are counted as part of the previous year
h is a representation of the date as number of days since a starting time. It can then be converted into a day of the week using: N = h%7
i.e. the remainder of the division of h by 7. N is the day of the week, with 0 being Saturday, 1 being Sunday,...
As a beginner I am kind of lost. Could anyone give me any tips on how to go about writing this program? Thank You!