Show 80 post(s) from this thread on one page
Page 1 of 3 123 Last
• 10-27-2010
dmeyers81
Background

Zeller’s Congruence is a formula that calculates the day of the week on which any date falls, given the month, day, and year. Zeller’s Congruence is:

(D + floor((M+1)*26/10) + Y + floor(Y/4) + floor(C/4) - 2*C) mod 7

where C is the century (the left-most two digits of the year, for example, 19 if the year is 1948), Y is the year within the century (0-99), D is the day number (1-31), and M is determined from the month by:

January M = 13, and subtract 1 from the year before computing C and Y.
February M = 14, and subtract 1 from the year before computing C and Y.
March M = 3
April M = 4
... ...
November M = 11
December M = 12

The value that results from Zeller’s Congruence is an integer in the range 0-6, where 0=Saturday, 1=Sunday, 2=Monday, 3=Tuesday, 4=Wednesday, 5=Thursday, and 6=Friday.

The mod operator

The mod operator in the formula refers to the mathematical modulo operation, as in modular arithmetic. It is closely related to the % operator in C++, but it is not identical. If integers A and B are both positive, then (A mod B) is the same as (A%B). However, if A is negative and B is positive, then (A mod B) is the same as (A%B)+B.

In Zeller’s Congruence, the first operand of mod may be negative. You may write a function to implement this operation, if you wish.

Assignment

Write a C++ function called weekday that uses Zeller’s Congruence to calculate the day of the week on which a chosen date falls. The parameters of the function are three integers that indicate the chosen month (1-12), day (1-31), and year, for example, 7, 4, and 1776 for July 4, 1776. The return value of the function is an integer in the range 0-6 to indicate the weekday on which the date falls.

Your program must repeatedly read a month, day, and year number, call the function to compute the day of the week, and call a void function to display the resulting day name. You must write the void function.

Make your screen look like the sample below. Terminate the program when the user enters zero for a month number.

Disclaimer

Zeller’s Congruence is based upon the Gregorian calendar, which was gradually adopted across the Western world beginning on October 15, 1582. It does not produce correct weekdays before the adoption of the Gregorian calendar.

Sample Run

Here is a sample to illustrate how the screen must appear when your program runs. You must strictly follow this format, wording, spacing, and alignment. The characters in blue are typed by the user. The other characters are output by the program.

Month----3
Day------21
Year-----1685
Weekday--Wednesday

Month----7
Day------4
Year-----1776
Weekday--Thursday

Month----12
Day------7
Year-----1941
Weekday--Sunday

Month----1
Day------26
Year-----1900
Weekday--Friday

Month----4
Day------4
Year-----2006
Weekday--Tuesday

Month----0
• 10-27-2010
ಠ_ಠ
And...?
• 10-27-2010
dmeyers81
How do you do it?....please lol
• 10-27-2010
ಠ_ಠ
Quote:

Originally Posted by dmeyers81

I what I heard.

• 10-27-2010
dmeyers81
Well you dont have to do it for me but if you would help me i would be very appreciative
• 10-27-2010
laserlight
So, what have you tried, and where are you stuck?
• 10-27-2010
Shakti
Attempt to solve the assignment and come back with specifc questions.
• 10-27-2010
MWAAAHAAA
Quote:

Originally Posted by dmeyers81
Well you dont have to do it for me but if you would help me i would be very appreciative

Hmmm, appreciative, in what way I wonder could that be?
• 10-27-2010
kmdv
I see, you no speak c++.

The only way we can help you is to tell you to try to do ANYTHING...
Code the formula, the program does not even need to compile...
If we do the easiest and most primitive part of the homework for you, what about the next one? Will you do it yourself? I don't think so...
• 10-27-2010
dmeyers81
I do know basic c++ but i feel like i took a class that is at a higher level than i should have

I don't even know what variables to declare or exactly how to write my own functions, i took notes and if i was explained it again maybe in a different sense it would maybe be clearer...i learned it today in class but it is very confusing to me

If i knew what the different functions i needed to use or exactly what loops i needed to use i believe i could figure out the algorithms to use in the body of those loops.

That's why i came here because i figured people on here who would be considered maybe experts, or if not, still at least have more experience than me, and would be able to help me out with it.

This is my fifth programming project and the first of which i came here for help.

But i guess never mind because everyone is so stuck on the fact that i want someone to type the whole program for me.
• 10-27-2010
Shakti
This is what happends when you let others do all the work for you. There is no way you "know basic c++" but dont know how to write your own functions, or what variables to declare on this basic assignment.

C programming.com - Your Resource for C and C++ Programming has tutorials, start from the beginning and try to learn something this time!
• 10-27-2010
dmeyers81
I learned about functions for the first time today and they were confusing to me.

All other programming projects we have had have only used if-statements, while-statements, do-while statements, and thats about the most of it.

We have also only had to return 0; and this project calls to return more than that.

This is the first programming project i have had that hasn't made any sense to me.
• 10-27-2010
Shakti
Then read the tutorials on the page i linked you! Go read that now! Try to solve the problem on your own and come back with specific problems.
• 10-28-2010
Elysia
We cannot do you the homework for you. And we cannot help you if you took a course that is over your head.
But we can help you eliminate confusion. But to do that, we need to know what you're confused about.
• 10-28-2010
Salem
First input the raw Y M D values and print them out.

> where C is the century (the left-most two digits of the year, for example, 19 if the year is 1948), Y is the year within the century (0-99)
Then calculate C and print that out as well as the modified Y

> January M = 13, and subtract 1 from the year before computing C and Y.
Then do this, print C, Y, M, D

etc etc
You're about half way there when you've done those steps.

Then post when you really get stuck.
Show 80 post(s) from this thread on one page
Page 1 of 3 123 Last