C Programming Gregorian Calendar Month Display Zellers Congr

C Programming

Gregorian Calendar Month Display– Zeller’s Congruence

Overview

In this assignment, the student will write a C program that graphically displays an accurate calendar month for a given date on the Gregorian Calendar with the assistance of Zeller’sCongruence. When completing this assignment, the student should demonstrate mastery of the following concepts:

Prompts and Input Validation

Decision Making

Looping

Mathematical Computations -Zeller’sCongruence

Console Output Formatting

In this project, you will write a C program that prompts a user for a calendar month and year and then displays a graphical representation of that calendar month from the Gregorian calendar.

The mathematically rigorous portion of this program involves the determination of the day of the week on which the first day of a given month occurs. This problem can be solved by using Zeller’s Congruence.

Zeller’s Congruence is defined as: h = ( q + (13 ( m + 1 ))/ 5 + K + K/ 4 + J /4 2 J )

The result h represents the day of the week on which a given calendar date occurs. The integer value of h maps to the days of the week in the following manner:

Saturday -> 0

Sunday-> 1

Monday-> 2

Tuesday -> 3

Wednesday -> 4

Thursday -> 5

Friday-> 6

The parameters are q, m, K, and J are used to represent the date for which the day-of-week determination is being made.

q represents the day of the month for the date in question. This value corresponds directly to the regular calendar date. February 11th, 1945 would have a q value of 11

m represents the month of the date in question. For Zeller’s Congruence, the mapping for the months is as follows:

January -> 13

February -> 14

March-> 3

April-> 4

May-> 5

June-> 6

July-> 7

August-> 8

September -> 9

October -> 10

November -> 11

December -> 12

February 11th, 1945 would have a m value of 14

K represents the year within the century of the date in question. J is the century. The K and J values can casually be conceived by breaking a 4-digit date into two parts. For the year 1945, J would have a value of 19 and K would have a value of 45. For the year 2013, J would have a value of 20 and K would have a value of 13

Once the user has been prompted for a month and year, your program should use Zeller’s Congruence to determine the day of the week on which the first day of that month occurs. At this point, enough information is known to draw anaesthetically pleasing graphical representation of that calendar month on the console

Please use commenting to explain

Solution

#include #include void main() { int leapdays, firstday, yr; long int normaldays, totaldays; clrscr(); printf(\"Enter year:\"): scanf(\"%d\",&yr); normaldays = (yr-l)*365L; leapdays = (yr-1)/4-(yr-1) /100 +(yr - 1)/400; totaldays = normaldays + leapdays; firstday = total days % 7; if(firstday == 0) printf(\"\ Monday\"); if(firstday == 1) printf(\"\ Tuesday\"); if(firstday == 2) printf(\"\ Wednesday\"); if(firstday == 3) printf(\"\ Thursday\"); if(firstday == 4) printf(\"\ Friday\"); if(firstday == 5) printf(\"\ Saturday\"); if(firstday == 6) printf(\"\ Sunday\"); printf(\"\ press any key to exit.\"); getch(); }
C Programming Gregorian Calendar Month Display– Zeller’s Congruence Overview In this assignment, the student will write a C program that graphically displays an
C Programming Gregorian Calendar Month Display– Zeller’s Congruence Overview In this assignment, the student will write a C program that graphically displays an

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site