Project 06 : Calendar
Due Saturday at 5:00 PM MST
The second part of the Calendar Program project (the first part being the structure part due earlier)
is to write the pseudocode for two functions: computeOffset()
and displayTable()
.
Compute Offset
Write the pseudocode for the function computeOffset()
.
This function will determine the day of the week of the first day of the month by counting how many days
have passed since the 1st of January, 1753 (which is a Monday and offset == 0
).
To do this, you will need to know about leap years.
That number (numDays
) divided by 7 will tell us how many weeks have passed.
The remainder will tell us the offset from Monday.
For example, if the month begins on a Thursday, then offset == 3
.
The prototype for the function is:
int computeOffset(int month, int year);
Please do not plagiarize this from the internet; you must use a loop to solve the problem.
The output for this function is the following:
Day | offset |
---|---|
Sunday | 6 |
Monday | 0 |
Tuesday | 1 |
Wednesday | 2 |
Thursday | 3 |
Friday | 4 |
Saturday | 5 |
You might want to test your algorithm (and get ahead on the next installment of the project) by also writing the code in C++ and testing it with a driver program. For example, we know that the January 1st 1753 is a Monday. Therefore, your driver program should output:
Enter a month number: 1 Enter year: 1753 Offset: 0
The second is the 1st of August, 2001 which is a Wednesday.
Enter a month number: 8 Enter year: 2001 Offset: 2
Display Table
Write the pseudocode for the function displayTable()
.
This function will take the number of days in a month (numDays
) and the offset (offset
)
as parameters and will display the calendar table.
For example, consider numDays == 30
and offset == 3
. The output would be:
Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
There are two problems you must solve: how to put the spaces before the first day of the month, and how to put the newline character at the end of the week. The prototype of the function is:
void displayTable(int offset, int numDays);
You may wish to verify your solution by writing code. This is part of Assignment 2.5
Assessment
The only deliverables for this project are two pseudocode functions.
Turning it in
Please turn this in through I-Learn using Assignment Submission. This should be a single document submission.
Grading
The grading criteria are:
Exceptional 100% |
Good 90% |
Acceptable 70% |
Developing 50% |
Missing 0% |
|
---|---|---|---|---|---|
computeOffset() : numDays30% |
Correctly count the number of days since the 1st of January, 1753 | Counts the number of days since 1/1/1753 with a minor bug | A serious bug exists in counting the days since 1/1/1753 | Insufficient detail to tell if the design will work | No pseudocode to count the number of days since 1/1/1753 |
computeOffset() : offset10% |
The best way was found to compute the offset from numDays | Offset is correctly computed from numDays, but is inefficient | The approach will not work | Insufficient detail to tell if the design will work | No pseudocode to compute the offset from numDays |
displayTable() : start of month30% |
Indents are correctly put in for the offset | One minor bug exists finding the 1st of the month | A bug exists in the algorithm | Insufficient detail to tell if the design will work | No pseudocode to find the start of the month |
displayTable() : end of the week30% |
Newlines are correctly put in after each Saturday | One minor bug in identifying the end of the week | The approach will not work | Insufficient detail to tell if the design will work | No pseudocode to find the end of the week |