Answered step by step
Verified Expert Solution
Question
00
1 Approved Answer
Zeller s congruence ( source:Click _ here _ for _ more ) is an algorithm devised by Christian Zeller to calculate the day of the
Zellers congruence source:Clickhereformore is an algorithm devised by Christian Zeller to calculate the day of the week for any calendar date. For todays Gregorian calendar, Zellers congruence is G q m U U V V mod where G is the day of the week means Saturday, means Sunday, means Monday, q is the day of the month q m is the month m and y is the year of the calendar date y Further, the above equation distinguishes V as the century that is V y and U as the year of the century that is U y mod Finally, there is an exception in Zellers congruence for the months of January and February which need to be counted as month and respectively, of the previous year. Thus, if m or m then we need to add months to the value of m and subtract year from y before we feed the values into the above equation. Your weekday calculation program should contain the following sections: Input Section: Prompt the user to enter a valid calendar date in the following format: Please enter a calendar date: Day, q Month, m Year, y We assume that the user will always enter proper input values, eg m q and y will always be inputted within the ranges outlined after Eqn. Therefore, there is no need to handle any invalid input in your program. Data Preprocessing: Deal with the exception for the months of January and February: if m then add to m and subtract from y Computation: Use Zellers congruence. Hint: The floor function is implicit in any integer division. That is if a and b are both integer variables, then a b a b Output Section: For the program output, you should print a numerical identifier to represent the computed weekday, and you should also print the result as a regular text string, ie Saturday, Sunday, Monday, or Friday. For the example above, the output should look as follows: For the calendar date the day of the week is This is a Wednesday. The bold lines in steps and are what you should observe on the terminal. You should save your program code in file named weekday.c you should also prepare a text file week day.txt briefly explaining how you designed your program and any hardships faced if any and prepare a typescript weekday.script which shows that you compile your program see section below for compilation details and run it Use the following dates as inputs for your typescript: the deadline for this assignment next New Years Day and the first day of classes at UCI For instructions on how to create a typescript, see Section Typescript at the end of this document. Compiling Your Code To test your program, it must be compiled with the gcc command. This command will report any errors in your code. To call gcc use the following template: zuma gcc sourcefile o targetfile Then, simply execute the compiled file by typing the following: zumatargetfile Below is an example of how you will compile and execute the "weekday" program: zuma gcc weekday.c stdcWall o weekday zumaweekday NOTE: If you encounter this error: zuma cc: error: unrecognized command line option stdc Then use this command before using gcc: zuma scl enable devtoolset tcsh Submit Your Work To submit your work, you have to be logged in to one of the following servers, zuma or crystalcove. Below is a checklist of the files you should have. In the hw directory, you should have the following files in your Linux account: weekday.c weekday.txt weekday.script We do require these exact file names ie do not modify the file names If you use different file names, we will not see your files for grading. Now, you should change the current directory to the parent directory containing the hw directory. Then type the command: zuma ~eecsbinturninsh which will guide you through the submission process. You will be asked if you want to submit the script file. Type yes or no If you type n or no or just plain return, they will be ignored and be taken as a no You can keep using the same command to update your submitted files until the submission deadline. After the submission deadline, you CANNOT modify the submitted files anymore
Zellers congruence source:Clickhereformore is an algorithm devised by Christian Zeller to calculate
the day of the week for any calendar date. For todays Gregorian calendar, Zellers congruence is
G q m
U U
V
V mod
where G is the day of the week means Saturday, means Sunday, means Monday, q is the day of
the month q m is the month m and y is the year of the calendar date y
Further, the above equation distinguishes V as the century that is V y
and U as the year of
the century that is U y mod
Finally, there is an exception in Zellers congruence for the months of January and February which need to
be counted as month and respectively, of the previous year. Thus, if m or m then we need to
add months to the value of m and subtract year from y before we feed the values into the above equation.
Your weekday calculation program should contain the following sections:
Input Section:
Prompt the user to enter a valid calendar date in the following format:
Please enter a calendar date:
Day, q
Month, m
Year, y
We assume that the user will always enter proper input values, eg m q and y will always be inputted
within the ranges outlined after Eqn. Therefore, there is no need to handle any invalid input in your
program.
Data Preprocessing:
Deal with the exception for the months of January and February: if m then add to m and subtract
from y
Computation:
Use Zellers congruence.
Hint: The floor function is implicit in any integer division. That is if a and b are both integer variables,
then a
b a
b
Output Section:
For the program output, you should print a numerical identifier to represent the computed weekday,
and you should also print the result as a regular text string, ie Saturday, Sunday, Monday, or Friday.
For the example above, the output should look as follows:
For the calendar date the day of the week is
This is a Wednesday.
The bold lines in steps and are what you should observe on the terminal.
You should save your program code in file named weekday.c you should also prepare a text file week
day.txt briefly explaining how you designed your program and any hardships faced if any and prepare a
typescript weekday.script which shows that you compile your program see section below for compilation
details and run it Use the following dates as inputs for your typescript:
the deadline for this assignment
next New Years Day and
the first day of classes at UCI
For instructions on how to create a typescript, see Section Typescript at the end of this document.
Compiling Your Code
To test your program, it must be compiled with the gcc command. This command will report any errors in
your code. To call gcc use the following template:
zuma gcc sourcefile o targetfile
Then, simply execute the compiled file by typing the following:
zumatargetfile
Below is an example of how you will compile and execute the "weekday" program:
zuma gcc weekday.c stdcWall o weekday
zumaweekday
NOTE: If you encounter this error: zuma cc: error: unrecognized command line option stdc
Then use this command before using gcc: zuma scl enable devtoolset tcsh
Submit Your Work
To submit your work, you have to be logged in to one of the following servers, zuma or crystalcove. Below
is a checklist of the files you should have.
In the hw directory, you should have the following files in your Linux account:
weekday.c
weekday.txt
weekday.script
We do require these exact file names ie do not modify the file names If you use different file names,
we will not see your files for grading. Now, you should change the current directory to the parent directory
containing the hw directory. Then type the command:
zuma ~eecsbinturninsh
which will guide you through the submission process.
You will be asked if you want to submit the script file. Type yes or no If you type n or no or
just plain return, they will be ignored and be taken as a no You can keep using the same command to
update your submitted files until the submission deadline. After the submission deadline, you CANNOT
modify the submitted files anymore
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started