Starting from:

$30

CS 159 – HW #05

CS 159 – HW #05

10 Points Possible
Problem: Given as input the year and occurrence number determine when that week begins and ends. Display the week
which will begin on the same day of the week as January 1st of the specified year. There is no input validation required for
this assignment. The input given will represent a “Start of week” date that occurs in the year specified.
• On page 300 of your C programming text there are several useful formulas given as part of problem 60. All input
will be integer data and your program will only be tested with years from 1800 to 2100.
• Notice that the name of the month is roughly centered above the 'e' in Wed.
Example Execution #1:
Enter year number -> 2021
Enter occurrence number -> 1
Start of week: Friday January 1, 2021
End of week: Thursday January 7, 2021
 January
-=-=-=-=-=-=-=-=-=-=-=-=-=-
Sun Mon Tue Wed Thu Fri Sat
 1 2
 3 4 5 6 7
Example Execution #2 (it is possible for a week to begin in one month and end in the next month):
Enter year number -> 2020
Enter occurrence number -> 9
Start of week: Wednesday February 26, 2020
End of week: Tuesday March 3, 2020
 February
-=-=-=-=-=-=-=-=-=-=-=-=-=-
Sun Mon Tue Wed Thu Fri Sat
 26 27 28 29
 1 2 3
Example Execution #3 (it is possible for a week to begin in one year and end in the next year):
Enter year number -> 2021
Enter occurrence number -> 53
Start of week: Friday December 31, 2021
End of week: Thursday January 6, 2022
 December
-=-=-=-=-=-=-=-=-=-=-=-=-=-
Sun Mon Tue Wed Thu Fri Sat
 31 1
 2 3 4 5 6
All course programming and documentation standards are in effect for this and each
assignment this semester. Please review this document!
Example Execution #4:
Enter year number -> 2019
Enter occurrence number -> 10
Start of week: Tuesday March 5, 2019
End of week: Monday March 11, 2019
 March
-=-=-=-=-=-=-=-=-=-=-=-=-=-
Sun Mon Tue Wed Thu Fri Sat
 5 6 7 8 9
 10 11
Example Execution #5:
Enter year number -> 2018
Enter occurrence number -> 18
Start of week: Monday April 30, 2018
End of week: Sunday May 6, 2018
 April
-=-=-=-=-=-=-=-=-=-=-=-=-=-
Sun Mon Tue Wed Thu Fri Sat
 30 1 2 3 4 5
 6
Example Execution #6:
Enter year number -> 2017
Enter occurrence number -> 19
Start of week: Sunday May 7, 2017
End of week: Saturday May 13, 2017
 May
-=-=-=-=-=-=-=-=-=-=-=-=-=-
Sun Mon Tue Wed Thu Fri Sat
 7 8 9 10 11 12 13
Example Execution #7:
Enter year number -> 2015
Enter occurrence number -> 23
Start of week: Thursday June 4, 2015
End of week: Wednesday June 10, 2015
 June
-=-=-=-=-=-=-=-=-=-=-=-=-=-
Sun Mon Tue Wed Thu Fri Sat
 4 5 6
 7 8 9 10
Example Execution #8:
Enter year number -> 2011
Enter occurrence number -> 30
Start of week: Saturday July 23, 2011
End of week: Friday July 29, 2011
 July
-=-=-=-=-=-=-=-=-=-=-=-=-=-
Sun Mon Tue Wed Thu Fri Sat
 23
 24 25 26 27 28 29
Example Execution #9:
Enter year number -> 2009
Enter occurrence number -> 32
Start of week: Thursday August 6, 2009
End of week: Wednesday August 12, 2009
 August
-=-=-=-=-=-=-=-=-=-=-=-=-=-
Sun Mon Tue Wed Thu Fri Sat
 6 7 8
 9 10 11 12
Example Execution #10:
Enter year number -> 2008
Enter occurrence number -> 36
Start of week: Tuesday September 2, 2008
End of week: Monday September 8, 2008
 September
-=-=-=-=-=-=-=-=-=-=-=-=-=-
Sun Mon Tue Wed Thu Fri Sat
 2 3 4 5 6
 7 8
Example Execution #11:
Enter year number -> 2007
Enter occurrence number -> 44
Start of week: Monday October 29, 2007
End of week: Sunday November 4, 2007
 October
-=-=-=-=-=-=-=-=-=-=-=-=-=-
Sun Mon Tue Wed Thu Fri Sat
 29 30 31 1 2 3
 4
Academic Integrity Reminder:
• Please review the policies of the course as they relate to academic integrity. The assignment you submit should be
your own original work. You are to be consulting only course staff regarding your specific algorithm for
assistance. Collaboration is not permitted on individual homework assignments.
Example Execution #12:
Enter year number -> 2006
Enter occurrence number -> 47
Start of week: Sunday November 19, 2006
End of week: Saturday November 25, 2006
 November
-=-=-=-=-=-=-=-=-=-=-=-=-=-
Sun Mon Tue Wed Thu Fri Sat
 19 20 21 22 23 24 25
Additional Requirements:
1. Add the homework assignment header file to the top of your program. A description of your program will need to
be included in the assignment header. This particular header can be added to your file by entering hhw while in
command mode in vi.
2. Each of the example executions provided for your reference represents a single execution of the program.
Your program must accept input and produce output exactly as demonstrated in the example executions, do not
add any “bonus” features not demonstrated in the example executions. Your program will be tested with the data
seen in the example executions and an unknown number of additional tests making use of meaningful data.
3. For this assignment you will be required to implement the user-defined functions (from chapter 4). Failing to
follow course standards as they relate to good user-defined function use will result in a zero for this assignment.
4. Revisit course standards as it relates what makes for good use of user-defined functions, what is acceptable
to retain in the main function, and when passing parameters by address is appropriate.
◦ In many cases user-defined function use should result in a main function that only declares variables and
makes function calls.
5. Course standards prohibit the use of programming concepts not yet introduced in lecture. For this assignment
you can consider all material in the first six chapters of the book, notes, and lectures to be acceptable for use.
◦ The use of arrays, including character pointers to represent string data, would violate requirements of this
assignment and result in no credit being awarded for your effort.
6. A program MUST compile to be considered for partial credit. The submission script will reject the submission of
any file that does not successfully compile on the guru server. The name of the source code file you attempt to
submit must be hw05.c, no variation is permitted.
Selected Course Programming and Documentation Standards Reminders:
• Code found inside the body of relevant selection and repetition constructs must be indented two additional spaces.
• Make use of { and } with all relevant selection and repetition constructs.
• See page 258 of your C programming text regarding the proper indentation for a switch construct.
• Use the course function header (head_fx vi shortcut hfx while in command mode) for every user-defined
function in your program.
◦ List and comment all parameters to a function, one per line, in the course function header.
◦ All function declarations will appear in the global declaration section of your program.
◦ The user-defined function definitions will appear in your program after the main function.
• Comment all variables to the right of each declaration. Declare only one variable per line.
• In general it is acceptable to initialize a variable declared in the local declaration section of a function. If the
expression used to initialize the variable is more complex than a constant assignment then it is
best to give the variable its first value inside of the executable statement section of the function.
• Notice that several programs (see program 2-9 on pages 74-75) in the programming text use a single line
comment to indicate the start of the local declaration and executable statement sections of the main function.
◦ At no point during the semester should these two sections ever overlap.
• Select meaningful identifiers (names) for all variables in your program.
When you submit... only the final successful submission is kept for grading. All other submissions are over-written and
cannot be recovered. You may make multiple submissions but only the last attempt is retained and graded.
• Verify in the confirmation e-mail sent to you by the course that you have submitted the correct file (must be
named hw05.c), to the correct assignment (hw05), and to the correct section.
• Leave time prior to the due date to seek assistance should you experience difficulties completing or submitting
this assignment. All attempts to submit via a method other than through the guru server as set up in the Account
Configuration Activity will be denied consideration.
Assignment deadlines... are firm and the electronic submission will disable promptly as advertised. We can only grade
what you submit as expected prior to the assignment deadline.
Auto-Grade Tool
• We have implemented what is being referred to as the auto-grade tool. At the time of a successful assignment
submission you may receive some feedback on your program in regards to course programming and
documentation standards. This feedback may include a potential deduction that you will receive once your
assignment is reviewed by your grader.
• It is expected that graders verify those notes identified by this tool to ensure that they are indeed applicable and
reasonable to the submission. Graders may make additional deductions for those standards not identified by the
new tool.
• We hope that this feedback helps with the enforcement of course standards, consistency in grading across
sections, and to encourage students to revise their work when problems are identified before the assignment
deadline passes. It is possible to resubmit an assignment for grading up to the advertised deadline. Only the final
successful submission is retained and evaluated.

More products